Custom Fields For Feeds: WordPress Plugin
![WordPress custom fields for feeds“](/user/media/2008/01/custom-feed.gif“ title=“WordPress custom fields for feeds)
- 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 ([download#13#hits])
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.
- Feature Image
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.
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:
- Using custom fields guide from the WordPress Codex.
- Tutorial series on using custom fields.
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.