wp_list_pages, if it finds no pages to display, shows random child pages instead because of a bug in get_pages()
|Reported by:||bobsoap||Owned by:||jackreichert|
|Component:||Query||Keywords:||good-first-bug needs-unit-tests has-patch 4.0-early|
How to reproduce:
- About page is published
- additionally, there is a number of parent pages
- these each have a number of children
- when calling wp_list_pages(), the "exclude" attr excludes all parent pages, and display only the About page.
This works as long as there is at least 1 other page published that is not in the list of excluded IDs. In this example, as soon as the About page is set to "draft", wp_list_pages stops working correctly.
So... with no other pages besides the excluded ones published, we do this:
=> wp_list_pages SHOULD return nothing, but instead it displays all child pages of the first parent page ID in the "exclude" attr (here: 3).
Now we now add the "exclude_tree" attr just for fun:
=> should again return nothing, but instead, it displays the first-ever published child page globally (here: a child page of 5).
It looked like random behavior at first but I've been able to identify the above pattern. I'm guessing it's a failing condition somewhere in the function.
Change History (21)
- Keywords needs-patch added
- Milestone changed from Awaiting Review to Future Release
- Summary changed from wp_list_pages, if it finds no pages to display, shows random child pages instead to wp_list_pages, if it finds no pages to display, shows random child pages instead because of a bug in get_pages()
- Component changed from General to Query
- Keywords good-first-bug needs-unit-tests added; wp_list_pages removed