X

Check if post has the_excerpt

Adding this PHP code to your wordpress theme will allow you to check if a post contains an excerpt. Wordpress will use the post as an excerpt when one does not exists so this is a great way to display the excerpt when not every post will contain one.



Code Snippet:


<?php
$my_excerpt = get_the_excerpt();
if($my_excerpt !='') {
the_excerpt();
}
?>

Comments  Leave a Reply

  1. Tweets that mention Wordpress Check it post has the_excerpt – wpsnipp.com Wordpress code snippets for your blog -- Topsy.com January 31, 2011 at 7:44 pm

    […] This post was mentioned on Twitter by HN Firehose, wp_freak. wp_freak said: #wordpress Check it post has the_excerpt http://bit.ly/h8VGwl […]

  2. WordPress Check it post has the_excerpt – wpsnipp.com WordPress code snippets for your blog…

    Adding this PHP code to your wordpress theme will allow you to check if a post contains an excerpt. WordPress will use the_content as an excerpt when one does not exists so this is a great way to display the excerpt when not every post will contain one…

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!