• Resolved Leslie Carson

    (@lunabug)


    I want to add the featured image to the RSS feed. I’m using this to add the image to the standard feed and it works fine; thought it should work for events as well…doesn’t.

    function featuredtoRSS($content) {
    global $post;
    
    echo 'Post id: ' . $post->ID;
    
    if ( has_post_thumbnail( $post->ID ) ){
    $content = '<div>' . get_the_post_thumbnail( $post->ID, 'medium', array( 'style' => 'margin-bottom: 15px;' ) ) . '</div>' . $content;
    }
    return $content;
    }
    
    add_filter('the_excerpt_rss', 'featuredtoRSS');
    add_filter('the_content_feed', 'featuredtoRSS');
    

    I’ve looked at the rss.php page and cannot find anything in there to help.

    How can I accomplish this?

    Thanks,
    Leslie

Viewing 9 replies - 1 through 9 (of 9 total)
  • There are plug in they do display the image of the post of “rss feed page”.
    not change the code because when you update the version of wp you erase everything the code ok?

    Thread Starter Leslie Carson

    (@lunabug)

    I know there are plugins, I don’t know if these plugins work with events manager?? I don’t update wp core or plugin files! I move them into my child theme and update there.

    I’d prefer to update code than add another plugin that loads a bunch of files that aren’t necessary. Considering that to add the images to your standard rss feed is a total of 13 lines of code, I’ll go that route!

    Where are you using your code?

    Thread Starter Leslie Carson

    (@lunabug)

    In my child functions.php file. It works great for the standard posts, just not for the event management posts. There seems to be only two files in the plugin that builds RSS feeds, em_rss.php and rss.php; I don’t see in either on how to add the image.

    It could be a priorities problem with add_filter.

    Another option would be to create a custom version of this file…
    /events-manager/templates/templates/rss.php
    …adding the_post_thumbnail function where you want the image to appear.

    https://developer.wordpress.org/reference/functions/the_post_thumbnail/

    This tutorial explains how to create custom templates that are upgrade-safe:
    http://wp-events-plugin.com/documentation/using-template-files/

    Thread Starter Leslie Carson

    (@lunabug)

    I thought this would work but it didn’t:

    
    <item>
    	<title><?php echo $EM_Event->output( get_option('dbem_rss_title_format'), "rss" ); ?></title>
    	<link><?php echo $event_url; ?></link>
    	<guid><?php echo $event_url; ?></guid>
    	<pubDate><?php echo get_gmt_from_date(date('Y-m-d H:i:s', $EM_Event->start), 'D, d M Y H:i:s +0000'); ?></pubDate>
    	<description><![CDATA[<?php echo $description; ?>]]></description>
    	<image><? the_post_thumbnail( 'medium' ); ?></image>
    </item>
    

    I tried the above, and get_the_post_thumbnail and tried making it a variable first then put it in the <item>. Nothing…. grrrrr.

    This shouldn’t be so difficult.

    Oh, and the child rss.php file is working as the <image> tag was not there but is now, it’s just empty.

    Thread Starter Leslie Carson

    (@lunabug)

    Well, I feel really stupid. I read the documentation and it’s all there, I just had to change some settings and now I have images in my RSS feed. While I was reading I found a few other tidbits that helped with some other issues.

    I’d like to modify my RSS feed to include more fields. Is that described in the documentation? I haven’t found any mention of that. Perhaps a link? Thanks.

    Thread Starter Leslie Carson

    (@lunabug)

    @garyhesse, here’s a link http://domain.com/wp-admin/edit.php?post_type=event&page=events-manager-options#formats

    Open the RSS box and it’s all there. Look at the “RSS description format” and be sure to look at the info in the link there for “Event Related Placeholders”

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Event images in RSS feed’ is closed to new replies.