Support » Themes and Templates » Template with RSS Feed and Image

  • Hi, I have created a template with an rss feed from an external site. However I am having trouble getting the images to come through. I know that when you click on each feed item that there is an image but I cant seem to get it to show.. I have tried get_attachment_image and a few other things including the simplepie way of doing it but no success.. Can anyone chime in, I’m sure there is a way to do this right?

    <?php function setup_the_rssFeed() {  
    	$feed = fetch_feed( '' );
    if ( ! is_wp_error( $feed) ):
    // Get a maximum of 5 items
    $maxitems = $feed->get_item_quantity( 5 );
    $items = $feed->get_items( 0, $maxitems );
    foreach ( $items as $item ):
    <p class="rss-widget">
    <a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a> <span class="rss-date"><?php echo $item->get_date( 'F j, Y' ); ?></span><br />
    <?php if (has_post_thumbnail( $post->ID ) ): ?>
    <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
    <img src="<?php echo $item->get_image_url ?>" height="200" width="200" />
    <?php endif; ?>
    <?php echo $item->get_description(); ?>
    else: // Returned WP_Error, unable to fetch the feed. ?>
    <p>There was an error fetching the feed, please try again later</p>
    <?php endif; ?>
    <p class="description">&mdash; Read more on <a href="#">The site</a></p>
    } ?>
  • The topic ‘Template with RSS Feed and Image’ is closed to new replies.