WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the following query on my category.php template:

    $paged = (get_query_var("paged")) ? get_query_var("paged") : 1;

The one thing that I've noticed is that this breaks my pagination...with this code the pagination returns "paged" in the url: http://example.com/?cat=12&paged=2, fortunately or unfortunately it's a simple issue with the url...instead of returning "paged" in the url, it should return "page" or http://example.com/?cat=12&page=2.

I have tried altering my code (as explained: http://codex.wordpress.org/Function_Reference/get_query_var for pages):

    $page = (get_query_var("page")) ? get_query_var("page") : 1;

But that doesn't work either...any ideas?


share|improve this question
up vote 0 down vote accepted

paged is correct unless you're using pretty permalinks, however, if you're just trying to alter posts per page for categories, you should be using the pre_get_posts action, there's no reason to use query_posts in the template:

function wpa85791_category_posts_per_page( $query ) {
    if ( $query->is_category() && $query->is_main_query() )
        $query->set( 'posts_per_page', 2 );
add_action( 'pre_get_posts', 'wpa85791_category_posts_per_page' );
share|improve this answer
Milo, I am using query_posts simply to restrict the number of posts per page...how do I apply your fix to just my category.php template? – Josh Rodgers Feb 13 '13 at 19:49
put that in your theme's functions.php file. – Milo Feb 13 '13 at 19:50
It works!! Thanks so much! – Josh Rodgers Feb 13 '13 at 19:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.