Forums

[resolved] Problem with RSS thumbnail code (20 posts)

  1. erikhgm
    Member
    Posted 8 months ago #

    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;
    }

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    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?

  3. erikhgm
    Member
    Posted 8 months ago #

    I am using the magazine style Mimbo theme.

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

  4. erikhgm
    Member
    Posted 8 months ago #

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

    http://pastebin.com/67T2y75z

  5. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    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.

  6. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    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?

  7. erikhgm
    Member
    Posted 8 months ago #

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

  8. erikhgm
    Member
    Posted 8 months ago #

  9. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    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?

  10. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    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() ); ?>" />

  11. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    Yup, it's definitely conflicting....

    <meta name="description" content="<img width="600" height="472" src="http://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....

  12. erikhgm
    Member
    Posted 8 months ago #

    So would this code be the best solution for this

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

  13. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    @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!

  14. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

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

  15. erikhgm
    Member
    Posted 8 months ago #

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

    Could I just remove the line?

  16. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    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.

  17. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Code that I've used in themes to create meta description & keywords: http://pastebin.com/sC4QN9ki

  18. Rev. Voodoo
    Volunteer Moderator
    Posted 8 months ago #

    Holy smokes @esmi, that's good stuff!

  19. erikhgm
    Member
    Posted 8 months ago #

    However I guess nowadays the meta tags are'nt as important for seo traffic right?

  20. esmi
    Theme Diva & Forum Moderator
    Posted 8 months ago #

    Meta description is still used by Google along with the initial content of your pages but for the most part keywords are ignored.

Reply

You must log in to post.

About this Topic