Support » Fixing WordPress » Custom fields in RSS feeds?

  • I’m trying to figure out how to get custom fields into an RSS feed. I’ve created a new custom field key called “colour” and I want to have the value in my feed as well as the usual title and description, eg:

    <description>A long fruit that you peel.</description>

    I’ve looked in Codex here:

    But I can’t figure it out. I’ve tried adding a line to the loop for colour to the RSS php file, but it doesn’t work:

    <?php while (have_posts()) : the_post(); ?>
    <title><?php the_title_rss() ?></title>
    <description><?php the_excerpt_rss() ?></description>
    <colour><?php get_post_meta($post->ID, $key, $single) ?></colour>
    <?php do_action('rss_item'); ?>
    <?php endwhile; ?>

    Hopefully I’m missing something simple, any help much appreciated!

Viewing 1 replies (of 1 total)
  • The loop doesn’t affect your RSS at all if you. if you know about filters you have to modify your RSS creating using

    <?php add_filter('rss_head', 'your_custom_fucntion_here') // rss 0.9 ?>
    <?php add_filter('rss2_head ', 'your_custom_fucntion_here') // rss2 ?>
    <?php add_filter('atom_head ', 'your_custom_fucntion_here') // atom ?>

    I cant’t really give you the whole code at the moment but if you need all the code I may be able to write it later on if not read a bit about the hooks here

Viewing 1 replies (of 1 total)
  • The topic ‘Custom fields in RSS feeds?’ is closed to new replies.