WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Showposts category page (16 posts)

  1. jeffreyvr
    Member
    Posted 3 years ago #

    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.

  2. Ganners
    Member
    Posted 3 years ago #

    Have you used "post_per_page" instead of "posts_per_page" ?

  3. jeffreyvr
    Member
    Posted 3 years ago #

    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!

  4. keesiemeijer
    moderator
    Posted 3 years ago #

    use this:

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

    or

    $current_category = get_query_var('cat');
    query_posts( 'posts_per_page=10&cat='.$current_category );
  5. jeffreyvr
    Member
    Posted 3 years ago #

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

    http://siteurl.nl/2011/01/page/2/?cat=19 results in a error.

  6. keesiemeijer
    moderator
    Posted 3 years ago #

    try it with this:

    <?php
    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);
    ?>
  7. jeffreyvr
    Member
    Posted 3 years ago #

    Same result. Thanks for reply!

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

  8. keesiemeijer
    moderator
    Posted 3 years ago #

    http://siteurl.nl/2011/01/page/2/ are date based archives and not a category archive

    What is that you want to do here?
    maybe it is this: http://wordpress.org/support/topic/combining-year-and-category-with-permalinks?replies=4

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

  9. jeffreyvr
    Member
    Posted 3 years ago #

    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:
    http://siteurl.nl/2011/01/?cat=1

    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.

  10. jeffreyvr
    Member
    Posted 3 years ago #

    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.

  11. 123milliseconds
    Member
    Posted 3 years ago #

  12. keesiemeijer
    moderator
    Posted 3 years ago #

    '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: http://siteurl.nl/2011/01/?cat=1 but normal links without the '?cat=1'.

  13. jeffreyvr
    Member
    Posted 3 years ago #

    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.

  14. jeffreyvr
    Member
    Posted 3 years ago #

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

    I'm happy. Thanks for the help guys!

  15. keesiemeijer
    moderator
    Posted 3 years ago #

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

  16. keesiemeijer
    moderator
    Posted 3 years ago #

    oops, to late. glad you found a solution.

Topic Closed

This topic has been closed to new replies.

About this Topic