Support » Plugin: Display Posts Shortcode » Trying to show excerpts only, but in absence of excerpt, content text appears

  • Resolved cbarnett


    Great plugin, it’s very useful. We are having a strange issue today though. We are trying to pull specific posts by id into different posts using shortcode such as this:
    [display-posts id="2275" image_size="thumbnail" include_excerpt="true"] 

    Which works fine, but on a few of the posts do not have an excerpt, they are automatically generating the first text of the post content followed by […] – this is undesirable for our uses. Perhaps if we controlled the excerpt length, but it is too long and looks odd with the image sizes when too long. And the odd thing, using the same shortcode on a different post with a separate post which also has no excerpt, it is not showing any text at all and is blank. But the code is identical save the post ids.

    Any ideas what might be happening? And at the very least can you tell me how to control the length of the text characters shown? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Bill Erickson


    What you describe is exactly how the excerpt in WordPress works:

    To modify it to work the way you want will require some custom coding. I’d start by using an output filter ( ex: ). Do something like:

    if( ! has_excerpt() ) $excerpt = ”;

    Okay. So, if I understand right, if I take out the include_excerpt parameter completely it will eliminate all instances of the excerpt OR content getting pulled in, right? I think if this is the case we probably will just use the parameter when we have a solid excerpt in place.

    Any ideas why even though many of my posts have no excerpt they aren’t showing even the content getting pulled in? As I mentioned in my first post, it seemed to be happening randomly – either showing content or nothing when the excerpt parameter was set to true and there was no excerpt specified for the post.


    Plugin Author Bill Erickson


    Correct, if you remove the include_excerpt part of the shortcode, no excerpt will be shown. If you are showing the excerpt and a manually written excerpt wasn’t provided, WordPress will make an excerpt using the first 55 words.

    There’s three possibilities for what you’re seeing:
    – You didn’t have include_excerpt in the shortcode (ex: you might have misspelled it)
    – The posts have neither an excerpt nor post content (ex: using on a post type that doesn’t support the content editor)
    – You have a plugin or theme that’s interfering with how WordPress generates excerpts.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Trying to show excerpts only, but in absence of excerpt, content text appears’ is closed to new replies.