Reputation: 75
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 ...
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.
Upvotes: 3
Views: 3968
Reputation: 75
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
Upvotes: 2