I have a shortcode for my content. This shortcode organizes a couple of things in my posts on the frontend.
However, when I look at my feed, the content in the entirely leaves out any content from my shortcode and only starts after the shortcode content.
When I take the content outside of my shortcode it shows up in the
Why is my shortcode content not showing in the description of the feed? It worked great before I introduced the shortcode!
I have found a similar issue here with no resolution: http://wordpress.org/support/topic/execute-shortcodes-in-feed-content
Update:
So I just read that shortcodes are being stripped by wordpress. How can I prevent this behaviour?
I have also tried this without any luck: the_excerpt and shortcodes
1 Answer
Ok I had to write my own custom excerpt like such:
function custom_excerpt($text="") {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
// $text = strip_shortcodes( $text );
$text = do_shortcode( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$excerpt_length = apply_filters('excerpt_length', 200);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
}
remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' );
add_filter('get_the_excerpt', 'custom_excerpt');