When trying to call get_the_excerpt()
the page does not return anything on posts that have no excerpt.
I thought WordPress usually ‘fake’ it and create one using the first x characters from the_content()
.
Or have things changed?
When trying to call get_the_excerpt()
the page does not return anything on posts that have no excerpt.
I thought WordPress usually ‘fake’ it and create one using the first x characters from the_content()
.
Or have things changed?
You must be logged in to post a comment.
Double check that you don’t have a check for
has_excerpt()
that’s hiding the “auto-generated” excerpt. Even ifget_the_excerpt()
returns something made frompost_content
,has_excerpt()
still returns false if the excerpt is empty.If that’s not the case, see if there’s a function that filters on
get_the_excerpt
that could be effecting this.To answer your question,
wp_trim_excerpt()
, the function that “fakes” an excerpt, filtersget_the_content()
whichthe_excerpt()
is just a wrapper function for. So that’s not the issue.In my case, I had,
and
POST_EXCERPT_LENGTH
was defined somewhere, which got deleted by mistake. So, excerpt was returning 0 characters.So, just return a value greater than
0
and it should fix the issue.