[wp-hackers] Modifying wp_list_pages() from a plugin

Pete Holiday pete.holiday at gmail.com
Wed Jan 5 21:21:36 UTC 2011

One of my plugins functions by forcing certain posts/pages to be private and
then showing them to certain logged-in users. It handles showing those posts
in the main loop using posts_where, but there are certain places (like
wp_list_pages()) where the query isn't run through that filter and, as a
result, the page list that's generated doesn't include the private pages
that it should.

Now, I haven't updated this plugin in nearly a year and a half, so I'm
probably a bit behind in terms of what's possible in a WP plugin these days,
but when I last checked, the only solution I could find was rewriting
wp_list_pages() and making that change available for users to add themselves
if they wanted to or wrapping wp_list_pages in my own function that users
could call instead that passed an include list. What I'm hoping for is
either a) some mechanism I wasn't aware of or b) another approach to solving
this problem.

I'm really hoping to avoid a situation where a user is required to update
their templates -- I'd like to just inject pages into the wp_list_pages()
results myself from the plugin -- but I'm open to any clever solution.


Pete Holiday

More information about the wp-hackers mailing list