Support » Fixing WordPress » Using get_archives command but leaving out a category

  • Resolved Tracey Grady

    (@tracey-grady)


    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?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Consider using get_posts() instead. It’s far more flexible.

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

    <?php
    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.

    Well colour me surprised at the cascading set of events.

    I’m really glad you’re happy. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using get_archives command but leaving out a category’ is closed to new replies.