RSS Feed
-
My Featured Image is not showing in my RSS feed. How can I get it to show? http://lewislanedesigns/feed
-
Hi! If you take a look at WPBeginner’s tutorial, you’ll see that you can easily add the featured image as follows:
function rss_post_thumbnail( $content ) { global $post; if ( has_post_thumbnail( $post->ID ) ) { $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>'; $content .= get_the_content(); } return $content; } add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' ); add_filter( 'the_content_feed', 'rss_post_thumbnail' );As you may know, Nelio External Featured Images only works if your theme uses either
get_the_post_thumbnailorthe_post_thumbnail. Apparently, this is the case in the RSS feed. Then, why does this not work?Our plugin prints the following image tag:
<img src="transparent.gif" style="background:url( http://domain.com/external-image.jpg )" />(it’s not exactly that tag, but it’s pretty close).
In order to overcome this issue, we need to use a slightly different image tag:
<img src="http://domain.com/external-image.jpg" />where the image’s URL is placed in the
srcattribute.TL;DR
If you want the image to work properly on RSS, use the following solution:
function rss_post_thumbnail( $content ) { global $post; if ( function_exists( 'uses_nelioefi' ) && uses_nelioefi( $post->ID ) ) { $img = nelioefi_get_thumbnail_src( $post->ID ); $content = '<p><img src="' . esc_attr( $img ) . '" /></p>'; $content .= get_the_content(); } else if ( has_post_thumbnail( $post->ID ) ) { $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>'; $content .= get_the_content(); } return $content; } add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' ); add_filter( 'the_content_feed', 'rss_post_thumbnail' );I hope this helps!
I entered that code into the function.php and still no images showing
Can you please share the link to your blog?
Is any of the “recent posts” (i.e. the ones that appear in the RSS) using Nelio EFI?
Yes they all are because I have been housing my images on flickr
I see you’re using version 1.3.x of our plugin, which (unfortunately) had quite a few bugs.
Please, try using the stable release 1.2.0. It’s much more reliable (even though it has some limitations).
is there a easy way to roll back to that version?
Yes, simply deactivate and uninstall your current version and install the plugin again.
There should be no problems, but I always recommend to backup your WordPress before installing new/updating plugins.
Ok I did that and still not seeing the images
Maybe you’re behind a cache? It’s pretty strange.
Anyway, try to tweak the previous code and see if you can modify your RSS file somehow (not necessarily using an image). For instance:
function rss_post_thumbnail( $content ) { return 'Testing...'; } add_filter( 'the_excerpt_rss', 'rss_post_thumbnail' ); add_filter( 'the_content_feed', 'rss_post_thumbnail' );WARNING: all posts in your RSS should have the same content now (“Testing…”).
If all posts have the same content, then the previous code for inserting featured images should work. If this latter change didn’t work, then the problem lies somewhere else.
Not sure I put it in right place cause it did nothing
The topic ‘RSS Feed’ is closed to new replies.