Wordpress RSS feed made browser friendly using XSLT

June 29, 2014 14:14 CEST, under technicalities category
last updated Jun 29th, 2014 14:24 CEST

When you click on a RSS feed icon or link within a random (WP or non-WP) site what you usually end up with is a plain text mess. See an example in the picture below (click to enlarge):

This is what your new subscribers most probably see when they hit the RSS button in WP in order to subscribe your feed. The question is - how to make this look better? There is a way and it is called XSLT. What you need to do is to add an xslt transformation to your RSS.

Our example assumes your WP feed is RSS2 (default 2.3 behavior). First of all you need to get hold of some transformation code. You can download the xslt wordpress rss transformation example here. Unzip this directory into your web root.

Second thing to do is to modify the /wp-includes/feedrss2.php file in order to tell it to do the transformation. It is a one line addition. Right after line 6 add another piece of code as per below (added code in red bold). Please do not forget to replace the youraddress.com with correct value.

line 6: <?php echo ‘<?xml version=”1.0″ encoding=”‘.get_option(’blog_charset’).’”?’.'>’; echo ‘<?xml-stylesheet title=”XSL_formatting” type=”text/xsl” href=”http:/youraddress.com/feedxsl/feeder.xsl”?’.'>’; ?>

And this is it. Your feed page should look similar to the picture above (click to enlarge). Or check it out here. The original xslt and css code was taken from this blog and modified in order to work in a generic way with the WP.

 


We value your interest and opinions ...
  1.  (required)
  2. please, share your email or web address to get in touch (not required) this form delivers the message to us, does not leave a comment below
  3. Captcha