Rss feed pulling shortcodes

Hi Support,

I’m using an RSS feed to pull information into a Grid I’ve set up - only problem is the excerpt is displaying the shortcodes before the excerpt text! :open_mouth:

I’ve checked and the text is in the excerpt section within cornerstone.

Is there a way of getting it to pull just the excerpt without the shortcodes?

Many thanks,

Nikki

Hi There,

Please add the following code under functions.php file locates in your child theme:

add_filter('the_excerpt_rss', 'x_custom_feed');
add_filter( 'the_content_feed', 'x_custom_feed' );
function x_custom_feed( $content ){
	global $post;

	if ( ! is_feed() )
		return $content;

	// Remove all shortcodes
	$content = strip_shortcodes( $post->post_content );

	return $content;
}
1 Like

Hi @thai,

That’s worked perfectly…

But, it has removed the thumbnail images that were feeding through. Is there something I could add to the code to make sure it keeps the thumbnails I had before?

Thanks, Nikki

Hello There,

Please edit the grid and indicate that the grid will use the featured image. You will have to make sure though that all your post must have a featured image so that the grid will pick it up.

Hope this helps. Please let us know how it goes.

Hi @RueNel,

THanks for the reply.

The grid is edited to display featured images, and they were displaying correctly before I inserted the code to remove the shortcodes from excerpts.

I’ve double checked and all of the posts still have featured images as well.

Thanks,

Nikki

Hi there,

Featured image is not part of the excerpt so it shouldn’t be affected unless those images are part of the content. Would you mind providing the exact URL where those items are being picked up? I just like to see if the image is added through Wordpress featured image or just inserted in the content.

Plus, the credentials are not working, especially the authentication code.

Thanks!

Thanks, @Rad

Here are those details…

Hi Nikki,

As previously stated, featured image is not part of the excerpt. Also RSS feed by default doesn’t include featured image. I am not sure how it works before on your site as seen on your shared screenshot. Adding featured image on RSS feed is possible with custom codes or by using a third party plugin. I have check your child theme functions.php and the code is not even added. And as expected, this: https://thegrowthidea.com/category/novaro-feed/feed/ doesn’t have featured image, that’s why on the grid here: https://novaropublishing.com/ there’s no image at all.

For the meantime, you can check on the following link that might help you resolve this issue.