[2.5] wp_list_pages “exclude” arg no longer works as advertised
I just upgraded to WP 2.5.
I am building navigation on the front page of my client’s site using wp_list_pages() with some excluded pages using the “exclude” parameter. This worked as expected in 2.3.x.
After the upgrade, the excluded pages are not showing up, but all of their sub-pages are. Additionally, they are rendering as
LIs at the same level as the top-level pages (i.e. they are not in a sub-list (ul) so are impossible to style invisible as a workaround). The docs specifically say:
“Excluding a Page will also exclude all of its sub-pages from the list to be generated.”
Does anyone know of a quick workaround I could enact to fix this issue? Is it a known issue? Searches of the forums/bug DB are not returning much for me.
Post it on trac, let the developers know.
Now to figure out if I need to downgrade for now…
You could, eventually, use the depth parameter to hide children Pages.
Wonder if this is related to my have_posts function problem?? See here…
If you are not using default permalinks, change the setting back to default permalinks and see if the problem goes away. There is something weird that custom permalinks is doing on some blogs!!!
This seemed to work for me.. Just remove / comment out the following line: $r[‘hierarchical’] = 0;
You can find that in wp-includes/post-template.php
Thanks vincentrich for pointing this out! http://wordpress.org/support/topic/164745?replies=2
Thanks turtlerabbit. Your solution of commenting out line 323 on /wp-includes/post-template.php worked great!
Thanks turtlerabbit! Good temporary fix. Just need to watch out for auto upgrades now…
Just for completeness if anyone’s searching, this bug also affects wp_list_pages handling of private or hidden pages, not just those specified by exclude.
In my case, wp_list_pages was not listing the private pages themselves, but would list all their (non-private) children (non-indented) at the top level of the li hierarchy. Potentially disastrous for anyone relying on this to rapidly hide whole site sections eg areas in development.
I just upgraded to WP 2.5.1, and it appears that wp_list_pages is behaving as expected again, without the need for the fix outlined by turtlerabbit above.
I wonder what 2.5.1 version you have. I just tested on localhost and wp_list_pages will still return the children of an exluded page. Trac doesn’t say it’s closed either.
I just upgraded one of my blogs yesterday from 2.5 to 2.5.1 and found this same problem. Thank you for providing the temporary solution. I would have never thought to go look in there.
dave_t said: Just need to watch out for auto upgrades now…
2.6.3 and still not resolved 🙁
What you can do if you don’t want to fiddle in the wp-includes source files is copy the ‘wp_list_pages’ function from wp-includes/post-template.php to the ‘wp-content/themes/*/functions.php’ file and (rename the function to something else of course, and don’t forget to delete $r[‘hierarchical’] = 0;).
- The topic ‘[2.5] wp_list_pages “exclude” arg no longer works as advertised’ is closed to new replies.