0

In addition to the normal feed that wordpress produces, i need to publish an additional feed of posts that have a certain custom field value.

I'm a bit lost on where to start. Any tip?

2
  • Do you mean an rss feed? Or do you just want multiple 'loops' of posts on a page? Oct 15 '11 at 18:07
  • yes i meant an RSS feed. Thx
    – pixeline
    Oct 16 '11 at 20:24
2

Something like this will add a /feed/special to your site.

add_feed('special','do_special_feed');

function do_special_feed() {
  query_posts(array(
    'meta_key' => 'key',
    'meta_value' => 'value',
  ));
  do_feed_rss2(false);
}

After putting it in a plugin or your theme's functions.php or what have you, you'll need to visit the Settings->Permalinks page at least once and save the settings, to get it to rebuild the permalink rules.

4
  • interesting. In the meantime i implemented a technique seen on Yoast, which works, but is more of a hack than your suggestion. yoast.com/custom-rss-feeds-wordpress
    – pixeline
    Oct 16 '11 at 20:01
  • Yeah, that method of the Page Template seems like a pretty weird hack when the ability to do this sort of thing easily is already built right in to WordPress. Creating custom feeds is easy.
    – Otto
    Oct 16 '11 at 21:54
  • I just tested this code. Any idea why after removing it from functions.php, the feed keeps available ?
    – Simon
    Mar 22 '12 at 15:23
  • Permalinks require a visit to the permalinks page to change. Also, check your caching plugins, if you have any.
    – Otto
    Mar 23 '12 at 3:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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