[resolved] Using get_archives command but leaving out a category (4 posts)

  1. Tracey Grady
    Posted 8 years ago #

    I want to post the title of recent blog posts on my front page and I am successfully using the following code to do so:

    <?php get_archives('postbypost', 5); ?>

    What I'd like to know is how to leave out a category. Also, how can I format things to show only a single category's posts?

  2. Ivovic
    Posted 8 years ago #

    Consider using get_posts() instead. It's far more flexible.

  3. Tracey Grady
    Posted 8 years ago #

    Thanks. I went to the link included in your reply and from that page I got the idea to use the following code:

    global $post;
    $myposts = get_posts('numberposts=5&category=1');
    foreach($myposts as $post) :
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>

    It's working exactly how I was hoping it would, and I'm using it in two separate places on the front page with a different category number in each. That's been a big help.

  4. Ivovic
    Posted 8 years ago #

    Well colour me surprised at the cascading set of events.

    I'm really glad you're happy. :)

Topic Closed

This topic has been closed to new replies.

About this Topic