Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

As discussed at WordPress admin screen very slow / timing out when editing or adding a new page/custom post

I am having a similar issue on a WP site containing 7,784 pages. Edit screens are slow loading due to the rendering of all 7k pages in the source code for the Page Attributes dropdown menu. Besides editing core, there must be a better way to deal with this. Seems like a flaw to render all pages on the edit screen.

Feedback from others with high volume/traffic WP sites much appreciated!

share|improve this question
add comment

3 Answers

Just use remove_meta_box function:

if (is_admin()) :
function my_remove_meta_boxes() {
    remove_meta_box('pageparentdiv', 'page', 'side');
}
add_action( 'admin_menu', 'my_remove_meta_boxes' );
endif;

If you need to set hierarchy of these pages (set post_parent for pages), you can still do it. Just add your custom meta box, and place there a select box with list of pages.

You have to be sure, that your query (to select these pages) is more efficient thatn original though. You can list pages without hierarchy and select only title and page_id (original query will retrieve all page data from DB, and it can be a lot of data, if there are many pages), or something like that.

share|improve this answer
add comment

Removing support for page attributes will prevent that box from appearing...

function remove_page_attribute_support() {
    remove_post_type_support('page','page-attributes');
}
add_action( 'init', 'remove_page_attribute_support' );

... but I don't know if you need attributes support or not. If you don't that is the fix.

If you do, you will need to remove the box as per @KrzysiekDrozdz's answer, but to be able to use those attributes you will have to rebuild that box, the original is here, in such a way that it works for you.

share|improve this answer
add comment

Another option is to filter the dropdown arguments before a call is made to wp_dropdown_pages. This function has a hook, but it happens after the query was made.

There are two places where it can be filtered: in Quick Edit mode and the Page meta box. But none is available for Options Reading or Theme Customizer.

enter image description here

The following are the default arguments and an example of filter to restrict pages by author (depth, child_of and exlcude seems good candidates too).

/*
$defaults = array(
    'depth' => 0, 
    'show_date' => '',
    'date_format' => get_option('date_format'),
    'child_of' => 0, 
    'exclude' => '',
    'title_li' => __('Pages'), 
    'echo' => 1,
    'authors' => '', 
    'sort_column' => 'menu_order, post_title',
    'link_before' => '', 
    'link_after' => '', 
    'walker' => '',
);
*/

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['authors'] = 'author_name';
    return $args;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.