WordPress.org

Ready to get started?Download WordPress

Forums

Limiting Category Counts in the Loop (4 posts)

  1. misterpatrick67
    Member
    Posted 3 years ago #

    Hello all,

    I have a home page that I currently have post counts set to 15. Problem is, specific categories are getting many more postings than others. Is there a way to limit specific categories to say 3 most recent posts, thus letting other categories maintain a presence on the home page? Not quite sure what the approach would be. Thanks!

  2. MichaelH
    Member
    Posted 3 years ago #

  3. misterpatrick67
    Member
    Posted 3 years ago #

    Thanks for the tip! I'll take a look and see how they are coding that. If anyone has any loop tips, those would be great as well as I prefer to not rely on plug-ins. Thanks!

  4. MichaelH
    Member
    Posted 3 years ago #

    Example of proper pagination:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('cat=3&posts_per_page='.get_option('posts_per_page').'&paged=' . $paged);
    ?>

    See the WordPress Default theme's wp-content/themes/default/index.php for example of using the template tags, previous_posts_link() and next_posts_link().

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags