• Resolved sagetips

    (@sagetips)


    I have a static front page (401k Planning) and would like to include an excerpt of the most recent post in the sidebar. I thought this would be no big deal, but my searching has yielded no workable results thus far.

    Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • hi – you can add some get_posts code to your sidebar. Something like this should do it. If you don’t want the permalink link or the title you can remove that part of the code

    <?php
     $lastposts = get_posts('numberposts=1');
     foreach($lastposts as $post) :
        setup_postdata($post);
     ?>
     <h2><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></h2>
     <?php the_excerpt(); ?>
     <?php endforeach; ?>

    This page has more info
    https://codex.www.ads-software.com/Template_Tags/get_posts

    Thread Starter sagetips

    (@sagetips)

    Thanks stvwlf!

    That works nicely.

    Awesome, exactly what I needed. Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Post Excerpt in Sidebar’ is closed to new replies.