Best way to add custom / magic / flutter fields into RSS feed

Using WordPress 3, creating write panels with Magic Fields, how do I add custom fields to my RSS feed?

For example, I have an ‘image of the day’ write panel, with a custom field for the photo credit. How can I include all that as part of my feed?

Read More

Thanks.

Related posts

Leave a Reply

2 comments

  1. you can use something like this

    function feed_magic_fields( $content ) {
      global $post, $id;
    
      if ( !is_feed() )
        return $content;
    
      // is feed
      $date = get('date_event');
      if( $date)
        $content .= $date
    
      return $content; 
    }
    
    add_filter( 'the_content', 'feed_magic_fields' );
    
  2. You can hook into your feed with the according filters and then add your stuff.

    Basically that codex page suggests (and that’s still valid, you find the feed templates inside /wp-includes/, the files start with feed-) that you hook into the_content and you check with is_feed() if you need to modify the content for the feed.

    To save you some hassles, you can register your whole plugin to activate on the do_feed_rss2 (or whichever you use) hook, so you do not need to check for is_feed().

    The contents of magic fields (custom fields to be precise) can be read out with existing functions, you find the documentation here: Custom Fields.