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.
you can use something like this
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 withfeed-
) that you hook intothe_content
and you check withis_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 foris_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.