WordPress.org

Ready to get started?Download WordPress

Forums

Having difficulty getting featured image to show in custom RSS feed (1 post)

  1. jakelisby@gmail.com
    Member
    Posted 1 year ago #

    Hi, I have a plugin [1] that aggregates all posts across my MU network and aggregates them at the root site. I also have a plugin [2] that takes those custom post type posts and outputs to a custom RSS feed. Their out of the box functionality doesn't include the Site name and Featured image, so I've added those, but I can't get the image to actually get included in the feed. I assume I'm doing something wrong, can anyone help guide me?

    if ( count( $posts ) > 0 ) {
    		foreach ($posts as $post) {
    			$author_display_name = $wpdb->get_var("SELECT display_name FROM " . $wpdb->base_prefix . "users WHERE ID = '" . $post['post_author'] . "'");
    			$blog_name = get_blog_option(get_current_blog_id(), 'blogname');
    			switch_to_blog( $post['blog_id'] );
    			$featured_image_id = get_post_meta(get_the_ID(), ‘_thumbnail_id’, true);
    			if ($featured_image_id) {$image_src = wp_get_attachment_image($featured_image_id, array(100, 100));}
    			?>
    			<item>
    				<title><?php echo apply_filters( 'the_title_rss', $post['post_title']); ?></title>
    				<link><?php echo $post['post_permalink']; ?></link>
    				<comments><?php echo $post['post_permalink'] . '#comments'; ?></comments>
    				<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post['post_published_gmt'], false); ?></pubDate>
    				<dc:creator><?php echo $author_display_name; ?></dc:creator>
    				<guid isPermaLink="false"><?php echo $post['post_permalink']; ?></guid>
                    <description><![CDATA[<?php echo apply_filters('the_excerpt_rss', wp_trim_excerpt($post['post_content'])); ?>]]></description>
                    <content:encoded><![CDATA[<span id="schoolName"><?php echo $blog_name; ?></span> <?php echo $image_src; ?> <?php echo apply_filters('the_content_feed', $post['post_content'], 'rss2'); ?>]]></content:encoded>
    				<wfw:commentRss><?php echo $post['post_permalink'] . 'feed/'; ?></wfw:commentRss>
    			</item>
    			<?php
    		}
    	}

    [1] wpmudev.org/project/post-indexer/
    [2] wpmudev.org/project/recent-global-posts-feed/

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by jakelisby@gmail.com
  • This topic is not resolved
  • WordPress version: 3.4.2