Wednesday, 22 January 2014

Display Default Excerpt When There is No Excerpt

While posting in wordpress blog, there may be some posts which do not have excerpts, in order to make excerpt we have add some text every time, but if we want to display a default excerpt for posts which do not have excerpts then add the following snippet in your single.php or any where in your theme(where you want to display)

$excerpt = get_the_excerpt();
if ( empty($excerpt) ) {
        echo "no excerpt for this posting.";
echo $excerpt;

No comments:

Post a comment