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!
Removing support for page attributes will prevent that box from appearing…
… 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.
Just use
remove_meta_box
function: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.
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.
The following are the default arguments and an example of filter to restrict pages by author (
depth
,child_of
andexlcude
seems good candidates too).You can easily disable page attribute dropdown using below code.
Just try to remove page attribute feature using admin_init hook. If it’s doesn’t work for you then try below code.
Try to remove meta box code using admin_head hook.
You will get more information about remove meta box and feature from this article.
I finally found a solution. Not the best one, but it’s working.
remove_meta_box and similar functions only works after the meta_box is added. Otherwise there is nothing to remove. So unfortunally that didn’t work out for me.
What was really working is a simple # to comment a line out of meta-boxes.php
So you prevent the meta-box of getting loaded with all includes and thats it. Pages loading fast now. =)