Custom Fields For Feeds: WordPress Plugin

  • Description: This puts images or videos into your feeds through the use of custom fields. You can alter the custom field Keys and what is displayed.
  • Version 1.0.1 Beta
  • License: GPL
  • Download Plugin (1269)

About this plugin

One of the things I wanted to accomplish in the custom fields tutorial series is adding the custom fields to the feed. So, if you’re reading this post through your feed reader, I hope there’s an image at the top of this post. If not, I suppose something went wrong. If you’re not reading this in a feed reader, then I suggest you subscribe to the feed now.

After completing work on the Structure theme, I decided that I needed to figure this thing out at some point. The theme uses multiple custom fields to display content on the site. In part, this plugin was made for that theme.

I only came up with this idea after I ran across Matt Mullenweg’s plugin, Adsense for Feeds, the other day. Basically, I took that script and made it display custom fields instead of ads.

Right now, it’s still in beta, and I’m sure I’ll work on it more. I just wanted to put this out there for those using the theme. Other than those using my themes, I’m sure this might come in handy if you like tinkering with PHP or use a lot of custom fields on your site.

The plugin was created to be modified. There’s no clear way to make this a “one-size-fits-all” plugin because I have no way of knowing what or how you’d want to display your content in your feed.

Using the plugin

You need to upload the “custom-fields-for-feeds” folder to your WordPress plugins folder. Then activate it from your WordPress administration panel.

To use this plugin out of the box, you must do a few things. First, you must know how to use custom fields. This is imperative.

The plugin will display one of four different items. Each one of these are Keys. Note that custom field Keys are case-sensitive. This is the order of the list the plugin checks for the custom fields. If one is used, then the others aren’t displayed.

  • Video
  • Image
  • Feature Image
  • Thumbnail

To use the “Video” custom field and if you’re not using one of my themes, you need to look at this tutorial on adding videos. It explains a lot.

If you’re using “Image,” “Feature Image,” or “Thumbnail,” it wouldn’t hurt to follow this tutorial on adding images to posts. I go into detail on how to accomplish this.

I’ll assume from this point that you know how to use WordPress custom fields.

To add a video (YouTube, Google, MetaCafe, etc.) to your feed using custom fields, you need to create a Key named “Video.” Give it a Value of the video’s “embed URL.”

To add an image, give it a Key of “Image,” “Feature Image,” or “Thumbnail.” The Value should be the “URL of the image” you want to use.

There’s also the option of adding alt text to your images. The Keys are:

  • Image Alt
  • Feature Image Alt
  • Thumbnail Alt

Just give them a Value of the alt text you want for the image.

The plugin will display the video or image at the beginning of the post in your feed. There’s also a smaller sample file that you can play around with.

Final thoughts

I’d like to push this plugin a little farther, give users the ability to display custom fields in various different ways. Right now, I want to allow users of my Structure theme to have their custom fields displayed in their feeds.

Please do not ask me questions about how to use custom fields on this post. This plugin is for those that already know how to use custom fields. If you want to learn how to use them, read these articles:

Feel free to push this plugin to its limits. This is really just a starting point. I’d love to hear your ideas on how to develop this plugin into something more powerful.

Once I click the “Publish” button, we’ll see if this thing is working. I hope my image shows up in your feed reader.

Update: The plugin definitely works.

33 Responses to “Custom Fields For Feeds: WordPress Plugin”

  1. Justin, I need to thank you heartily for this. I actually don’t know that I’d ever use this plugin as is, but it finally got me to work on fixing the RSS feed for my link blog (I entered it as “Website”). Thanks to this the primary page I’m linking to in the title of each post–which I use a custom field for–shows up in the feed.

    The solution’s not as elegant as I might like, but it works and is a step in right direction. And I’m certain that if your post hadn’t shown up in my feed reader today I wouldn’t have worked on it anytime soon. So, thanks.

  2. Justin Tadlock

    [...] than it did, which is certainly a good thing. I also have to thank Justin Tadlock for providing the impetus for finally making this [...]

  3. Awesome! You finally did. Thank you so much! ;) I’ve been waiting for someone to do this. Good job.

  4. David
    Thanks. As you mentioned, the solution isn’t elegant, but it works. I’d really like to push it a bit farther, so I’m sure I’ll be testing different things out on this blog. Please share anything you’d like to see or any other ideas you have.

    Donalyza
    Yeah, I finally got tired of my images not showing up in posts and just happened to come across Matt’s plugin. I couldn’t believe how simple it was to integrate the two concepts.

  5. I will surely need this and use this one. Great work!!! Really…

  6. Noli
    Thanks. I’d love to see more people using it. It’ll give me motivation to continue building on it. :)

  7. Hi Justin,
    I’m using a different theme (Showcase by WPDesigner) which also works with custom fields to show images. I’ve installed and activated your plugin and changed the thumbnail line to $image = get_post_meta($post->ID, 'Thumbnail Full', $single = true); to reflect the name of the custom field that I’d like to use but no image (or even the missing alt text message) shows up in my feed.

    Do you know if your plugin may have a conflict with any other plugins, or any reasons why it may not be working on my blog?

  8. PJ
    It’s hard to say without actually looking at the theme’s code, and I can’t do that because of the license restrictions. As far as I know, there are no conflicts with other plugins.

    You should definitely run some tests on a local version if you’re modifying the code though. I would never suggest editing a plugin without testing it locally before uploading it online. You can at least publish as many posts as you want to see if it’s working correctly. Also, did you publish a new post after you installed the plugin?

  9. Thanks for replying, Justin. I’ve published a few posts whilst the plugin’s been running, with no success.

    I didn’t really change the plugin code though, I just changed the “Thumbnail” field to “Thumbnail Full”, which is the custom field I needed for my blog.

    I’ve never really thought about installing a local version on my computer, but it sounds like a helpful tip. I’ll let you know if I have any success with that.

  10. PJ
    Another blogger pointed out that his images weren’t showing up either, but he doesn’t have any content in his posts. He only uses custom fields. So, I’ve updated the plugin, but you can just add this code:

    add_filter('the_meta','custom_fields_for_feeds');

    Below this in “custom-fields-for-feeds.php”:

    add_filter('the_content', 'custom_fields_for_feeds');

    Maybe that’ll help.

    I think everyone should run a local copy on their computer, especially before using a new theme or plugin. Things can really screw up if you just upload things to your site. There are several tutorials on how to do this, but I’ve used Tamba2’s Xampp tutorial before. It might take a little patience setting it up, but it’s well worth it.

    It really comes in handy when testing things with custom fields because you don’t get a second chance after hitting that publish button with your real blog.

  11. PJ
    Actually, just ignore the code above. I thought there was a problem when there’s no content, but it seems to be working for me on my local version without the extra line.

  12. Justin Tadlock

    [...] Custom Fields for Feeds [...]

  13. Justin Tadlock

    [...] Custom Fields for Feeds [...]

  14. i loved that custom fields. i never seen an usage of custom fields like that. You did a good job.. Thanks a lot !

  15. Huseyin
    It was actually pretty simple once I saw that AdSense for feeds plugin. I’d been searching for a decent solution before it magically appeared.

  16. In using this plugin with the Options (Light) theme it doesn’t seem like videos are being included in the feed from the custom fields?

    The videos appear perfectly on the site (home page and postings) but are missing from the feed itself, however pictures are working fine.

    Could this be because I’m only including the videos via the custom fields when writing a new post and not placing the full embedding code into the post body? It seems like that would cause a double instance of the video on the postings pages, but I figured I’d ask.

    Thanks

  17. Hey Justin, first off… Great Plugin!

    However… I can’t seem to get it work. I have a key named Thumbnail and I have my image path correct in the value. In fact, I didn’t even touch your plugin at all. I just activated it. I have the FeedSmith Plugin and the Custom Field GUI plugin installed with this plugin. I don’t have any other plugins that would seem to affect it. Are there issues with these plugins that would make your plugin not work?

  18. Justin Tadlock

    [...] Custom Fields for Feeds [...]

  19. Justin, I just wanted to leave an update to my earlier comment about videos not showing correctly. I’ve set my feed to run through Feedburner and now the videos are showing in the feed properly.

    I didn’t make any other changes, so either it was just some odd glitch or maybe there’s something in how WP version 2.3.3 handles the feed output that you might want to look into. I’m not sure but just wanted to mention it for your benefit.

    Great plugin (and theme in Options), thank you so much!

  20. RickRi
    I’m not sure. I’ll have to look into it. I’m using the FeedSmith plugin on this blog and it works. Also use the Custom Field GUI on my test blog.

    Scott
    Thanks for the update. I quickly updated the plugin for the Options theme because it was originally for Structure only, so I need to do a little more testing to be sure it’s functioning as expected.

    I use Feedburner on this blog but just the standard WordPress feed through my test bog. Both seem to work for me. Like I said though, I still need to do some testing with the Options theme to make sure all the custom fields are getting through.

  21. well, i don’t have any content in the post, just two custom fields. is this a problem, i know you said to an earlier comment that it wasn’t??

  22. Sorry for posting so many times but I just wanted to add the php that I have to see if it’s right or not. Here it is…

    ID, ‘Thumbnail’, $single = true); ?>

    Thanks again for any help, I’m starting to go crazy over this.

  23. <codeID, ‘Thumbnail’, $single = true); ?>

  24. Ahhh…. I’m soooo sorry for posting so many times. I didn’t use the “code” tag. You can delete those posts if you want.
    Anyway, here is the php code that I’m using.

    ID, 'Thumbnail', $single = true); ?>

  25. echo $image = get_post_meta($post->ID, ‘Thumbnail’, $single = true); ?>

  26. I’m really sorry for posting so many times, but I really want this plugin to work for me. I just can’t seem to get the thumbnails to show in my feed. I’m getting desperate here.

  27. Justin Tadlock

    [...] kalian bisa lihat pada Home/About oh yah satu lagi theme ini sudah otomatis support dengan plugin custom-fields-for-feeds, flickrRSS, Related Posts, Popularity Contest, Get Recent Comments jadi kalian tinggal menginstal [...]

  28. Hello Justin

    I need to put any character in my content area to show custom fields data in feed reader.

    Must be somewhere in your plugin you have added this condition, I want to know how can I remove that condition? So that without any content my custom field can be show in feed reader.

    Actually I’m finding this solution for my CSS Gallery theme user:
    http://www.osdesigner.net/wordpress-themes/css-gallery-theme/

    Thanks for your effort :)

  29. I’m trying to download this plugin, but its taking me to a 404 page. Is it no longer available?

  30. Same like darleene.. the Download Link is Not Working!!

    seems to be a promising plugin. Please correct the link asap.

  31. For those of you still looking, I found what appears to be this plugin @

    Edited

  32. Justin Tadlock

    [...] Enhanced WP contact-form - when I wanted to create a “contact me” this plugin was all I needed. [...]

  33. Justin Tadlock

    [...] by Kafkaesqui and custom-fields-for-feeds-wordpress-plugin by Justin [...]

Leave a reply

Log in or Register



XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> 
<blockquote cite=""> <cite> <code> <del datetime=""> <em> 
<q cite=""> <strong>