Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

Thanks.

share|improve this question
add comment

2 Answers 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.

share|improve this answer
add comment

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' );
share|improve this answer
    
thanks for adding some code, that's basically what I meant no need to global $post, $id btw. –  hakre Aug 27 '10 at 21:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.