WordPress the_excerpt not returning content from the Excerpt field

The problem I’m having is that the_excerpt() isn’t returning the content from the post’s “Excerpt” field. Instead, it’s returning the first part of the post, as though the “Excerpt” field was empty.

My code is very simple – inside the loop, I have …

Read More
if(has_excerpt()) {
  the_excerpt();
} else {
  the_content();
}

Is there something that needs to be done to tell wordpress to use the “Excerpt” field.

Thanks in advance for your help.

Related posts

1 comment

  1. I resolved this as follows ..

    I discovered that the excerpt is stored in the WP_Post class field post_excerpt, so I got it directly with …

    $the_post = get_post();
    $post_excerpt = apply_filters('the_excerpt', $the_post->post_excerpt);
    echo $post_excerpt;
    

    I would be happy to hear from anyone if there is a better way, and also why the_excerpt() doesn’t give that field content.

    Thanks for your replies

Comments are closed.