• It’s possible do it with get_archives or i must do a loop for the sidebar like this

    <?php $my_query = new WP_Query(‘cat=1&showposts=10’); ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • You could also do a mini-loop:

    <?php query_posts('category_name=reviews&showposts=5'); ?><?php while (have_posts()) : the_post(); ?><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    <?php endwhile; ?>

    That will give you the last 5 posts from the “reviews” category. Of course, you’d need to put your own category name in there.

    You might want to wrap it in an unordered list as well, like so:

    <ul class="internallink"><?php query_posts('category_name=reviews&showposts=5'); ?><?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?></ul>

    See it in action on the main page of my site: http://www.solostream.com.

    CG-Samecat was designed to do just that btw… grab a bunch of links from a given category for display on the sidebar or as a ‘similar items’ list under a post.

    -d

    pixelfight

    (@pixelfight)

    I am using that code to pull the last 5 from one category, now how can I modify the above code to pull the last entry from each category? thanks in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘The latest post from a category in the sidebar’ is closed to new replies.