Thank you for your feedback.
I have not seen this problem before, but I will look into how pages are sorted. Are you using any plugin to modify the sort order, hierarchy or status of the pages?
Hi Joachim… I just tried a test and disabled all my plugins with the exception of CAS and the problem is still there.
What’s also a little interesting: If I goto CAS [Pages > Most recent] then I do see a hierarchy of those recent pages. But if I look at CAS [Pages > View All] and look at the same tree area as in Most Recent, the page hierarchy is not displayed.
Let me know if you want me to try anything.
One more note… I’m also seeing this same behavior when looking at the hierarchical categories. It seems if looking at the “most recent” tab then the display is hierarchial, but when viewing the “all” tab it is a random display.
I can confirm this issue and will look into it.
Can you check whether this problem also exists when selecting pages in Appearance > Menus?
From what I can tell, when I go to Appearance > Menus > Pages > Show all
or Appearance > Menus > Categories > Show all
it all seems to work ok.
If you go to the Pages overview screen and sort the pages by title, is the hierarchy showing correctly?
In my test (WordPress 4.1rc1), this, along with the Menus screen, will not show the hierarchy correctly. That can mean that the “bug” is in WordPress Core.
You’re right, if I sort pages by “title” then it won’t display in hierarchical order, but then I wouldn’t expect that as it is sorting by something other than the parent / child order. But when I then click on “Pages” again in the admin pages it resorts into the proper hierarchical order. Somewhere WP is sorting on the hierarchical key order. It’s not the page ID, title, or order, but there must be some other key field it is sorting on. This is a related reference, but it’s beyond me. http://codex.wordpress.org/Function_Reference/wp_list_pages
Also, even if I click on “Title” in pages, when I then go back to Appearance > Menu the pages are all listed in hierarchical order as expected.
After having taken a deeper look at it, it seems like WordPress fetches _all_ pages when the hierarchy should be maintained, i.e. it is not sorting on the SQL side, but rather in the backend. This is why the hierarchy is lost/off when sorting alphabetically.
And in the “All Pages” tab in the sidebar editor, the pages are sorted alphabetically.
If you want to change it right now, you might be able to fix it by opening the file modules/post_type.php and look for the function meta_box_content
.
In it, $this->_get_content
is called. Remove the order
and orderby
parameters from it. Let me know if this solves the problem.
That definitely helped. I commented the order
and order by
parms and it improved things, but some of the hierarchy was still missing in the view all tab and the pages were scattered later in subsequent pages of the “View All” tab.
That got me thinking that the next thing to look at was the paging. So I changed posts_per_page
from 20 to 40 as shown below and that really helped. Obviously a problem when the hierarchy structure length exceeds the posts_per_page
value.
protected function _get_content($args = array()) {
$args = wp_parse_args($args, array(
'include' => '',
'post_type' => 'post',
'orderby' => 'date',
'order' => 'DESC',
'paged' => 1,
'posts_per_page' => 40,
'search' => ''
));
Hope that helps…