• Resolved erikhgm

    (@erikhgm)


    I have tried the different codes there are out there to include a thumbnail in the RSS feed and they do insert the thumbnail in the feed but when I view a post with a thumbnail attached to it on my website, the post excerpt is showing up on the top of the page before the wrapper.
    Does anyone know why this is?
    Thanks
    Erik

    // THIS INCLUDES THE THUMBNAIL IN OUR RSS FEED
    add_filter( ‘the_excerpt_rss’, ‘voodoo_insertThumbnailRSS’ );
    add_filter( ‘the_content_feed’, ‘voodoo_insertThumbnailRSS’ );
    function voodoo_insertThumbnailRSS( $content ) {

    global $post;

    if ( has_post_thumbnail( $post->ID ) )
    $content = ” . get_the_post_thumbnail( $post->ID ) . ” . $content;

    return $content;
    }

Viewing 15 replies - 1 through 15 (of 19 total)
  • I’m not 100% sure as I’ve never had any issues with that code on any site.

    I wonder if your theme is using the_excerpt_rss for some reason?

    What theme are you using? Also, if you switch to twentyeleven for a moment just to test, does the problem go away?

    Thread Starter erikhgm

    (@erikhgm)

    I am using the magazine style Mimbo theme.

    When I switch to twenty eleven yes the problem goes away.

    Thread Starter erikhgm

    (@erikhgm)

    I just found out that there is a line of code in the header which includes ‘the_excerpt_rss’

    https://pastebin.com/67T2y75z

    That’s not related. It’s trying to output a meta description for your site’s pages and won’t impact on your RSS feed.

    Hmmm….

    I think that if an image is filtered onto the_excerpt_rss, and added into that meta description through that, it may jack things up…

    you have a link to see your source code?

    Thread Starter erikhgm

    (@erikhgm)

    However it displays the excerpt on top of the page when viewing post with an thumbnail attached to it.

    Thread Starter erikhgm

    (@erikhgm)

    Tsk! Bad Voodoo ?? Just realised you’re altering the_excerpt_rss – which is fine if your theme doesn’t use it anywhere but the RSS feed. However, in theory, this should just bork the meta description – not the feed, yes?

    Just a hunch but, in the code you posted above, try changing:

    <meta name="description" content="<?php the_excerpt_rss(); ?>" />

    to:

    <meta name="description" content="<?php strip_tags( the_excerpt_rss() ); ?>" />

    Yup, it’s definitely conflicting….

    <meta name="description" content="<img width="600" height="472" src="https://matvarupriser.se/nyhetsrum/wp-content/uploads/2011/09/Annelieframtidensmat.jpg?e2686d" class="attachment-post-thumbnail wp-post-image" alt="Annelieframtidensmat" title="Annelieframtidensmat" />Annelie Hellstr?m, VD f?r FramtidensMat, i kr?nikan: G?van att f? bidra till ett enklare liv med goda middagar!
    " />

    Is what is getting output to your head….

    I’m not totally sure how to go about fixing it, I’ve never used the_excerpt_rss within a theme…. I don’t think swapping that out for the_excerpt will work, I think that would bring in other stuff….

    Thread Starter erikhgm

    (@erikhgm)

    So would this code be the best solution for this

    <meta name=”description” content=”<?php strip_tags( the_excerpt_rss() ); ?>” />

    @esmi just saw your post. I believe that it only did bork the theme, not the feed.

    Is there a better way to get where I’m going? Images in the rss feeds? If so, I’m all ears!! er… eyes!

    @erikhgm: It should work. At worst, it won’t help but it shouldn’t break anything else.

    Thread Starter erikhgm

    (@erikhgm)

    I just tried changing the code but its the excerpt still shows up.

    Could I just remove the line?

    technically

    <?php if (is_single() || is_page() ) : if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <meta name="description" content="<?php the_excerpt_rss(); ?>" />
    <?php endwhile; endif; elseif(is_home()) : ?>
    <meta name="description" content="<?php bloginfo('description'); ?>" />
    <?php endif; ?>

    Could be removed entirely…. that just sets up meta description

    An SEO plugin (such as Yoasts WordPress SEO) could add in the descriptions if you want them, probably more effectively

    It’s up to what you wish to do

    Also, if there is a way to improve my code up above for putting images into the rss feed, I’d love to see that to.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Problem with RSS thumbnail code’ is closed to new replies.