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.
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!