I have a plugin I'm modifying in which I need to return the manual excerpt if it exists, and if not, nothing. How would I go about that? Here's my code so far:

            $excerpts = sprintf(
                '<a href="%1$s">Apply</a>',
                esc_attr( sprintf( __( '%s' ), get_the_excerpt() ) ),

It works, but it only returns the automatically generated excerpt. Is there an argument for get_the_excerpt() to do what I want?

  • 1
    If I'm not mistaken, $post->post_excerpt holds the manual one and the_excerpt() will generate it if it doesn't exist.
    – Howdy_McGee
    Commented Apr 26, 2016 at 18:04

1 Answer 1


Answering my own question. Solved with an if else statement using has_excerpt.

            if( has_excerpt ( $_post, ID ) ) {
                 $author = sprintf( '<a href="%1$s">Apply</a>', esc_attr( get_the_excerpt( $_post ) ) );
            } else {
                 $author = '';

It only makes sense, really.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.