WordPress parent select need to be removed

Hi i have a WordPress installation with over 35000 pages which are sorted into trees like so …
enter image description here

There is an ongoing issue with page edit loading very slowly or failing to load at all.
Through long trial and error and research i found it to be caused by the loading of parent select (10K pages crashes it)

on previous similar projects i disabled the parent select through the following function but it still seems to run a huge query causing it to run out of memory

add_filter( 'quick_edit_dropdown_pages_args', 'limit_parents_wpse_106164' );
add_filter( 'page_attributes_dropdown_pages_args', 'limit_parents_wpse_106164' );

function limit_parents_wpse_106164( $args ) {
  $args['child_of'] = 4009;
  //Id 4009 post dosn't exist
  return $args;
 }

is there a way to dequeue the Query from happening and removing parent select from page attribute section all together?

Thank you in advance.

1 Answer
1

Per comments a way around it is to set the post_type to something that isn’t a hierarchical type in the filter, as the wp_dropdown_pages() function used to populate the select calls get_pages() which just returns without doing anything if the post_type isn’t hierarchical. So using a non-existent post_type works:

function limit_parents_wpse_106164( $args ) {
    $args['post_type'] = 'does_not_exist';
    return $args;
}

Note that the original filter idea comes from @brasofilo here.

Leave a Comment