1

Is it possible to show the excerpt for a known and single post (on the Home Page) while in the loop?

I tried each of these and none of them work:

<?php echo the_excerpt('10'); ?>
<?php echo the_excerpt(10); ?>
<?php $theExcerpt = get_the_excerpt('10'); echo $theExcerpt; ?>
<?php $theExcerpt = get_the_excerpt(10); echo $theExcerpt; ?>
2

the_excerpt() is one of a few template tags that do not accept a post ID as a parameter. Instead, you need to set up the global $post, run your tags, then restore it:

if ( $_post = get_post( 10 ) ) {
    setup_postdata( $post = $_post );
    the_excerpt();
    // Any other template tags for this post
    wp_reset_postdata();
}
  • Perfect. Thanks @TheDeadMedic...it worked exactly as I needed it to. – tammy Feb 11 '15 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.