Forums

Recent Blog Posts in Sidebar (3 posts)

  1. medli
    Member
    Posted 3 years ago #

    How do you display the title of your top 3 recent blog posts in your sidebar along with a little paragraph about the post?

  2. MichaelH
    Volunteer
    Posted 3 years ago #

    Something like this in your sidebar.php

    <?php
    $posts=get_posts('post_type=post&amp;showposts=3');
    if ($posts) {
    foreach($posts as $post) {
    setup_postdata($post);
    ?>
    <?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    
    <?php the_excerpt(); ?>
    <?php }
    }
    ?>

    Note until Automattic fixes the forum, code is somewhat mangled so the "$post=..." should be:

    $posts=get_posts('post_type=post&showposts=3');

  3. triplemoons
    Member
    Posted 2 years ago #

    What's the rest of the code?

    This partially works, but it replaces the content area as well.

Topic Closed

This topic has been closed to new replies.

About this Topic