Support » Fixing WordPress » Showposts category page

  • Resolved Jeffrey van Rossum


    Hello all,

    I’ve got a problem.

    I have a category.php wich displays the category that has been selected. I wan’t to show 10 post per page. But when I add a query_posts with showposts=10 or post_per_page=10 it shows all categories, and not just the one selected.

    I can’t solve it with my ‘paged’ settings because that is set on 100 posts.

    Hope it’s clear what I mean. Hoping for support.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Ganners


    Have you used “post_per_page” instead of “posts_per_page” ?

    I used posts_per_page and showposts, and it seems to work… But It then shows all categories… Not just the selected one.

    Thanks for your answer!

    Moderator keesiemeijer


    use this:

    global $query_string;
    query_posts( $query_string . "&posts_per_page=10" );


    $current_category = get_query_var('cat');
    query_posts( 'posts_per_page=10&cat='.$current_category );

    Thank you! It worked. Got another problem though. Pagination doesn’t work. It gives an error when browsing trough a specific category. results in a error.

    Moderator keesiemeijer


    try it with this:

    if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
    elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
    else { $paged = 1; }
    global $query_string;
    query_posts( $query_string . '&posts_per_page=10&paged=' . $paged);

    Same result. Thanks for reply!

    It works untill there’s placed an ?cat=1 (or whatever category id you wish) in the url.

    Moderator keesiemeijer

    (@keesiemeijer) are date based archives and not a category archive

    What is that you want to do here?
    maybe it is this:

    if not can we have a link to the categorypage you want to paginate.

    Correct. It’s a date based archive…

    I’m using the following code:
    <?php wp_get_archives('cat=1'); ?>

    It gives me the months and generates links like this:

    Now with that kind of link the paging doesn’t work. As soon as I remove the ?cat=1 part, it works.

    Thanks for your help so far.

    I’m not able to update my previous post for some reason, so here a new one.

    The pagination doesn’t work because of my ‘paged’ settings in wp-admin. It’s on 100 post per page right now, but if I change it to 10 the pagination works.

    Is there a way to use multiple ‘paged’ settings? It needs to be on 100 because of my searchresults.



    Moderator keesiemeijer


    ‘cat=1’ is not a valid parameter in wp_get_archives() so it will show by default monthly archives. If I try it with <?php wp_get_archives('cat=1'); ?> on my testserver it doesn’t give me links like: but normal links without the ‘?cat=1’.

    I have a plugin installed that makes it posible to use cat=1 in the wp get archives method.

    When I use the loops you (keesiemeijer) and 123milliseconds mentioned it will show 10 posts per page, but It generates a lot of pages ( to navigate in)… pages that don’t excist because there aren’t that many posts in the category. That’s why the error page is showing up.

    It seems that I’ve found a solution…This plugin allows to set multiple post limits.

    I’m happy. Thanks for the help guys!

    Moderator keesiemeijer


    I guess this is a plugin issue. How many posts do you have in the category you are querying? What plugin are you using?

    Moderator keesiemeijer


    oops, to late. glad you found a solution.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Showposts category page’ is closed to new replies.