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.

 

 

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

Leave a comment