4

Is there a way for me to check if the user has explicitly set an excerpt? I need to call the excerpt only if they've specified something in the excerpt field, and not an automatically shortened version of the content.

2 Answers 2

6

Try this:

if ( has_excerpt( $some_post_id ) ) {
    // Do something here?
} else {
    // Or here?
}

References:

1
  • Perfect, thanks. Probably should've checked the conditional tags documentation before posting, haha. I'll accept as soon as it'll let me. Dec 12, 2014 at 17:41
2

This is an alternative to the answer by @tf

The manual excerpt set by a user is stored as a WP_Post object, $post_excerpt.

post_excerpt    string  User-defined post excerpt

You can access this excerpt inside the loop with $post->post_excerpt

You can simply do a check to see if this object is empty or not

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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