twofivethreetwo
Member
Posted 7 months ago #
I am using the_content() and the_excerpt() on my index page. Its a resource site where we link to others. With the_content() (and more) we have our text and then we use the_excerpt() to quote the site we are linking to. The problem arises when we post our own articles. We have no need for the_excerpt() and need to not display it if we left it blank. However doing a simple if (the_excerpt()) doesn't work since wordpress just uses content for it.
Is there another way to do this? Since I have the_excerpt() wrapped with blockquote, is there a way to wrap the whole thing in an if statement?
twofivethreetwo
Member
Posted 7 months ago #
Was able to figure it out after some more browsing... For those interested in the same here is what mine looks like:
<?php if (!get_the_excerpt()) { ?>
<!-- show nothing if no ex
<?php } else { ?>
<blockquote>
<?php the_excerpt(); ?>
</blockquote>
<?php } ?>
Somebody else might have a better way to do this, but this works for me right now.
rianrietveld
Member
Posted 1 month ago #
Found this useful from
http://wpcult.com/display-the_excerpt-only-if-there-is-text/
if ( !empty( $post->post_excerpt ) ) :
the_excerpt();
else :
false;
endif;