Forums

how to only display latest 2 posts in asides (1 post)

  1. Travel-Junkie
    Member
    Posted 5 years ago #

    hey there,

    i'm using this code from the codex to display asides in my sideblog:

    <?php
    if ($posts) : foreach ($posts as $post) : start_wp();
    ?>
    <?php if (in_category(14)) { ?>
    <div class="asides_sidebar">

    <?php echo $post->post_excerpt ?> <?php the_content(); ?>
    <small><?php comments_popup_link(__('#'), __('(1)'), __('(%)')); ?>
    <?php edit_post_link('Edit', ' — '); ?></small>
    </div>
    <?php } ?>
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    how do i need to change the code, so that only the latest 2 posts get displayed? been trying for the last 2 hours and it's driving me crazy
    thanks, b

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.