WordPress Featured Image Src to RSS feed

I am working on a job posting website that uses wordpress for McNairy County. In the process I become interested in apple IOS development and created a app using wordpress’s RSS feed. Nativly the job postings company logo does not display automatically.

After a little research I found a the add_action parameter that would allow me to add the src for each item. Then I told the function echo the src of the featured image inside the <companyLogo> element.

add_action('rss2_item', 'add_my_rss_node');

function add_my_rss_node() {
 global $post;
 if(has_post_thumbnail($post-&gt;ID)):
 echo"&lt;companyLogo&gt;".wp_get_attachment_image_src( get_post_thumbnail_id( $post-&gt;ID ), 'thumbnail' )[0]."&lt;/companyLogo&gt;";
 endif;
}


I noticed while editing this file two things. One if you are using the wordpress backend editor and something doesn’t send correctly the whole site will go down. Two if you are opening your feed with a web browser like chrome then each time you refresh you need to close and reopen a incognito window to see the changes.

Leave a Reply

Your email address will not be published. Required fields are marked *