Question about wp_get_archives() abilities (6 posts)

  1. backpages
    Posted 8 years ago #

    I'm using the wp_get_archives(); template tag to retrieve a list of the 10 most recent posts for a sidebar on a theme I'm building. I've read through the documentation, but I can't find answers to two questions. I'm currently using this code:

    '<?php wp_get_archives('type=postbypost&limit=10'); ?>

    So, it's pulling in the last 10 posts. But I only want it to pull in from a specific category AND I want to display the date along with the title of the post. I can't find any arguments to use to in the template tag to accomplish this. For instance this doesn't work in trying to pull posts from a certain category:

    <?php wp_get_archives('type=postbypost&limit=10&category="music"'); ?>

    Is either one (or both) of these things possible? Any help or advice would be greatly appreciated. Thanks!

  2. Jeremy Clark
    Posted 8 years ago #

    You'll probably have to do a mini loop in the sidebar.
    Has what you need.

  3. backpages
    Posted 8 years ago #

    Thank you very much, I'll take a look at that.

  4. backpages
    Posted 8 years ago #

    Perfect! That was exactly what I needed, thank you very much. Works great.

  5. ch0p5
    Posted 7 years ago #

    Could I see the code you used to do that? I looked at the mini loop link and couldn't make sense of it.

  6. Mark / t31os

    Posted 7 years ago #

    Here's what i use in my sidebar (although i offset the posts, i removed that for this example).

    <ul id="recent">
    <?php $posts = get_posts('numberposts=5');?>
    <?php foreach ($posts as $post): setup_postdata($post); ?>
    	<li<?php if($currentpost == $post->ID) echo ' class="current"'; ?>>
    		<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    <?php endforeach; } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic