No excerpt is generated for shortcode-encapsulated posts.
-
Although get_the_excerpt() and the_excerpt() are supposed to generate an excerpt if none exists, if the content of a post is encapsulated in shortcodes (and no excerpt exists) then apparently no excerpt is being generated.
So, for example, when I created a (very) simple post using Bootstrap shortcodes to test this:
[container]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
[/container]No excerpt was returned by either get_the_excerpt() or the_excerpt().
I tried this with various combinations of Twitter Bootstrap grid shortcodes and got the same result. Text outside the shortcodes was returned in the excerpt.
I did confirm that get_the_excerpt() calls wp_trim_excerpt(), which successfully calls get_the_content(”). However, it then attempts to strip the shortcodes using strip_shortcodes($text) and this returns an empty string, rather than the content encapsulated by the shortcodes.
So — just clarifying — is this the way strip_shortcodes() was designed? –to strip all text from between all shortcodes? Or am I missing something…
Thx.
- The topic ‘No excerpt is generated for shortcode-encapsulated posts.’ is closed to new replies.