Problem using the 'rss2_item' action hook
-
Hey all,
I’m trying to add some custom data to the feeds that are being produced by my website, but the data is not being added. I’m using the code below, which seems to be doing something, as my other site which is reading the feed tells me there are no results, but is fine when this code is not used.
I’ve never delved in to the world of RSS manipulation before, so I’m hoping that this is a fairly simple problem!!
/** * Adds the 'event_date' meta value to a feed */ add_action('atom_entry', 'add_event_date_to_feed'); add_action('rdf_item', 'add_event_date_to_feed'); add_action('rss_item', 'add_event_date_to_feed'); add_action('rss2_item', 'add_event_date_to_feed'); function add_event_date_to_feed(){ global $post; $event_date_raw = get_post_meta($post->ID, 'event_date', true); if($event_date_raw && $event_date_raw !== '') : $date_object = DateTime::createFromFormat('D, d M Y H:i:s +0000', $event_date_raw); $event_date = $date->format('U'); else : $event_date = ''; endif; printf("\t\t".'<eventDate>%1$s</eventDate>'."\n", $event_date); }
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Problem using the 'rss2_item' action hook’ is closed to new replies.