divPress

Discover WordPress. Get acquainted from level-one about the nuances of developing for Wordpress. Learn to code like a Pro using advanced WordPress coding.

Do subscribe to get regular updates via RSS.

How to check if a post has the Excerpt field filled manually

A function to check if the excerpt was automatically generated by wordpress or manually entered in the Excerpt field



the_excerpt( ) displays the content filled in the Excerpt field (if filled manually) or else it will display an automatic excerpt which refers to the first 55 words of the post’s content.

To check if the Excerpt was manually filled, wordpress has a function called has_excerpt( ). So, if you dont like WP’s auto-excerpt, you can write a few lines of code like:

1
2
3
4
5
<?php if ( has_excerpt( ) ) {
    the_excerpt();
} else {
    the_content();
} ?>

Was this post useful? Share on Twitter or Facebook and spread the love.   

Related Posts

Now What?

Leave a Reply

Allowed Tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>