Adding the image tag to Wordpress's rss headers
The RSS specification allows you to have an <image> element in the header of your RSS feed. A long time ago, if you used Wordpress, you'd have to edit the wp-rss.php file and be very careful when you upgraded to new releases, or your change could be lost.
But if you use a modern version of Wordpress, you should take advantage of the do_action('commentsrss2_head') hooks* in the feed-rss... .php files.
Here's what you'd do: Add the following code to your theme's functions.php file:
Take care to actually put an image file in the path specified, and adjust the width and height accordingly.
Et, voila! Now your feeds have images, and they're forwards compatible with future versions of Wordpress. Oh, did I say future versions of Wordpress? Excuse me, I have to:
Blam! Upgraded. Sweet.
* Also rss2_head and rss_head, just so I cover the appropriate Google terms.
But if you use a modern version of Wordpress, you should take advantage of the do_action('commentsrss2_head') hooks* in the feed-rss... .php files.
Here's what you'd do: Add the following code to your theme's functions.php file:
function add_my_rss_image()
{
echo '<image><title>', bloginfo_rss('name'), '</title>';
echo '<url>', bloginfo_rss('stylesheet_directory'), '/images/button.gif</url>';
echo '<link>', bloginfo_rss('url'), '</link>';
echo '<width>88</width><height>31</height>';
echo '<description>Description of your blog.</description></image>';
}
add_action('rss2_head','add_my_rss_image');
add_action('rss_head','add_my_rss_image');
add_action('commentsrss2_head','add_my_rss_image');
Take care to actually put an image file in the path specified, and adjust the width and height accordingly.
Et, voila! Now your feeds have images, and they're forwards compatible with future versions of Wordpress. Oh, did I say future versions of Wordpress? Excuse me, I have to:
svn sw http://svn.automattic.com/wordpress/tags/2.6/
Blam! Upgraded. Sweet.
* Also rss2_head and rss_head, just so I cover the appropriate Google terms.
Comments