How to Change the Number of Posts in a Category in WordPress
In my test example, I’m going to change the number of posts displayed for two categories on my blog – Politics, and Book Reviews. I want to category pages of the former to only display 1 post per page and 2 posts for the latter. To do this, we’re going to modify the posts query object that is run before every page is rendered. I had talked about the query_posts function when discussing the WordPress loop in general. We’re going to be using a similar technique. The “pre_get_posts” action hook allows us to manipulates the query containing the posts for a particular page before it actually executes. Since the query is passed by reference and not by value, there is no need to return anything. Any changes we make to the variable are directly reflected at the source.