Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

Double check that you don't have a check for has_excerpt() that's hiding the "auto-generated" excerpt. Even if get_the_excerpt() returns something made from post_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, filters get_the_content() which the_excerpt() is just a wrapper function for. So that's not the issue.

share|improve this answer
    
Theres no has_excerpt() condition before I print get_the_excerpt(). Although I have still checked the functions file and there is nothing that I can see that could be filtering get_the_excerpt. –  Imran Oct 4 '12 at 23:02
    
Does it work if you use the_excerpt()? –  mrwweb Oct 5 '12 at 1:20
    
Also having this problem - is there a solution? –  benedict_w 16 hours ago

In my case, I had,

function mytheme_excerpt_length() {
  return POST_EXCERPT_LENGTH;
}
add_filter('excerpt_length','mytheme_excerpt_length');

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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