• (Firstly, great plugin, very useful. Thanks for developing it.)

    Not sure if I’m just doing the wrong thing but I was hoping that when listing blog posts (in archives, etc) using the_excerpt() would still show the content grabbed by RPS Include Content. Instead, it just returns the actual, full, shortcode that’s being used in the content, e.g. [rps include blog=”1″ post=”1″]

    I’m assuming this is simply because the_excerpt() isn’t the same as the_content() so I’m expecting a bit too much for everything to automatically work.

    I’ve tried using wp_trim_words(get_the_content(),20) as a substitute for the_excerpt() and this works fine with Posts with real content but has the same problem as using the_excerpt() and RPSIC, i.e. the full shortcode is returned instead of the grabbed content from the parent Post.

    Are there any filters or a method of storing the content in a variable that might get around the above problem?

    Thanks for any help.

    https://wordpress.org/plugins/rps-include-content/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author redpixelstudios

    (@redpixelstudios)

    Glad you find the plugin useful. If we understand correctly, you are introducing a shortcode into the excerpt of a post. If so, the behavior you are seeing is likely because shortcodes are not processed when introduced into excerpts by default. In order to get this to work, you might want to try adding the following filters to your theme’s functions.php file.

    add_filter( 'the_excerpt', 'shortcode_unautop');
    add_filter( 'the_excerpt', 'do_shortcode');

    Let us know how it works out.

    Thread Starter nudone

    (@nudone)

    Thanks for the quick reply. I will test the filters and report back.

    Just to clarify (I thought my post would be a bit confusing), the use of the_excerpt() IS being used but the Post’s content is actually all in the main Editor panel, i.e. not in the “Excerpt” panel that appears below it.

    I’m was allowing the_excerpt to do its automatic thing and grab the first few words from the main content when the “Excerpt” panel is empty.

    I did try putting content inside the “Excerpt” panel as a, hopeful, workaround but that didn’t work either.

    Back in a minute as I’ll now text the filters.

    Thanks.

    Thread Starter nudone

    (@nudone)

    Okay, firstly, an apology…

    I was using “wp_trim_words(get_the_content(),##)” not “the_excerpt()”. So this explains why it was displaying the shortcode itself and not the grabbed content.

    Using the filters does work so that a good solution and, probably, the more sensible method to what I was trying to do (or thought I was trying to do until I spotted I was using wp_trim_words).

    Just to try and explain in more detail (if it helps with developing RPS Include Content), I tend to create themes for clients that use the_excerpt() on listing pages, e.g. archives, blog, search, BUT don’t expect the client to know or care about the “proper” use of the Excerpt panel below the main Editor. When used like this the_excerpt falls back to just grabbing the first 55 words from the main content rather than show nothing (because the Excerpt panel is emtpy).

    Because of the above, it seems that if RPSIC is grabbing content from a Post without any Excerpt (panel) content, there is nothing to pass through to the_excerpt(). Which I admit makes sense as the_excerpt() is looking for content from the Excerpt panel… but, the_excerpt() is then meant to fallback to using the first 55 words from the main content. In this situation, it looks like when the_excerpt() tries to fallback to the main content it finds the RPSIC shortcode and gives up and nothing is output (not even the shortcode text; that is only displayed when using wp_trim_words(get_the_content()).

    It would be great if this “fallback” feature of the_excerpt() still manage to work with the RPSIC shortcode. But I perfectly understand if this is just going way too far.

    Thanks again for a great plugin.

    Plugin Author redpixelstudios

    (@redpixelstudios)

    No worries. You have a valid point and we will definitely look into adding the fallback for a future release. Thanks for your time and efforts!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘pass through the_excerpt() or wp_trim_words()’ is closed to new replies.