#5708 closed defect (bug) (invalid)
wp_list_pages() will not list subpages by ID if the parent is not included.
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 2.3 |
| Component: | General | Keywords: | list subpages |
| Focuses: | Cc: |
Description
Here is a simple example.
If the parent of page 23 is not in the list the page 23 will not pe displayed. Here is the code, I tested 5 times:
<?php
wp_list_pages('include=5,9,13,23&title_li=<h2>' . ('Poetry') . '</h2>' ); ?>
This will display all 4 pages because 13 is a parent of 23.
<?php
wp_list_pages('include=5,9,23&title_li=<h2>' . ('Poetry') . '</h2>' ); ?>
This will display only 5 and 9 because 13, the parent of 23, is not in the list.
So, you can not list subpages if their parent is not in the list.
Change History (3)
Note: See
TracTickets for help on using
tickets.
This is not an issue with the latest wporg builds.
I've tested with similar page structure, and it appears to be fine.
In your case, 23 should be displayed at the very end, because it is an "orphan page" - pages whose parents do not exist.
Note that the comment for walk() function has:
so as long as 0 is passed in, every page will be displayed, regardless of it is an orphan page or not. However, if 0 is not passed in, orphan page will be skipped.
By default, 0 is used in wp_list_pages().
Below is the logic in the code where the orphan page is handled, just FYI.
wp-includes/classes.php
function walk( $elements, $max_depth)
/*
*/
....