
use the hook!
It is easy to go in and hack the core WordPress files to change the hard-coded number, but I wanted to find a way to do it with a hook. That way, I could one day change the number of posts shown using controls in the interface.
Though there is no filter provided for the number of posts displayed, I hit upon a method of doing this which I would like to share. Perhaps someone will point out a better way, but for now this is making me happy
The trick is to hijack the query string just for the query that produces the table of posts. Here’s what I did:
/** * Extend the number of posts displayed in the Edit Posts */ function dapl_query_string($query_string) { global $pagenow; if (is_admin() && $pagenow == 'edit.php') { $query_string = str_replace('posts_per_page=15', 'posts_per_page=100', $query_string); } return $query_string; } add_filter('query_string', 'dapl_query_string');
4 Comments
You got me thinking – I think there’s at least 3 ways to skin this cat with hooks or filters… I might have to write something up on that now that you got my brain churning.
That helped a lot … thanks a ton
Hi Gregory – thank you for posting the solution to this one – please excuse my obvious ignorance, but – which file would I insert the code into?
many thanks
Andrew
Big thank you to Gregory – I just successfully created my first plugin with your code – and of course understand a little more about the whole wordpress platform.
Thank you for taking the time to follow up – I very much appreciate it.
Andrew