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?


1 Answer 1


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' );
  • 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? Commented Feb 13, 2013 at 19:49
  • put that in your theme's functions.php file.
    – Milo
    Commented Feb 13, 2013 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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