WordPress.org

Ready to get started?Download WordPress

Forums

Limit Categories. (4 posts)

  1. picard102
    Member
    Posted 7 years ago #

    Is there a way to limit the categories displayed to only the 5 most recently posted in Categories?

    There are 3 main Categories (Past, Present, Future) and subcategories under those. I want to list the subcategories but limit it to displaying no more then 5 or 10 of the most recently posted in Category.

  2. moshu
    Member
    Posted 7 years ago #

    You will have to try it again.
    Do you mean you want to display only the subcategories in which there are posts recently published?
    I don't remember seeing any solution for something like this.

  3. picard102
    Member
    Posted 7 years ago #

    I want it to display 5 to 10 of the sub-catagories most recently posted in.

  4. David Yeiser
    Member
    Posted 7 years ago #

    You could try this:


    <ul>
    <?php
    $posts = get_posts('numberposts=10');
    foreach($posts as $post) :
    setup_postdata($post);
    ?>
    <li><?php the_category(); ?></li>
    <?php
    endforeach;
    ?>
    </ul>

    Let me know if this works, I'm at work so I can't test it for myself.

Topic Closed

This topic has been closed to new replies.

About this Topic