WordPress.org

Ready to get started?Download WordPress

Forums

Display Posts Shortcode
[resolved] Trying to show excerpts only, but in absence of excerpt, content text appears (4 posts)

  1. cbarnett
    Member
    Posted 1 year ago #

    Hi,
    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!

    http://wordpress.org/extend/plugins/display-posts-shortcode/

  2. Bill Erickson
    Member
    Plugin Author

    Posted 1 year ago #

    What you describe is exactly how the excerpt in WordPress works: http://codex.wordpress.org/Function_Reference/the_excerpt

    To modify it to work the way you want will require some custom coding. I'd start by using an output filter ( ex: http://www.billerickson.net/code/display-posts-shortcode-show-author/ ). Do something like:

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

  3. cbarnett
    Member
    Posted 1 year ago #

    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.

    Thanks!

  4. Bill Erickson
    Member
    Plugin Author

    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic