PHP Code Share: RSS Blog Feeds on your website

I don’t have much time today, so I’ll tackle a smaller topic as opposed to the larger “site search”  I was going to take on. 😉  This is just as valuable for a site nowadays though, so hopefully others can be spared a little bit of headache with this info.

Everyone and their mama, papa, and siblings have a blog these days.  And others like myself have a website in addition to that.  So the logical next step for me was how do I include my latest blog entries into my personal website.  It may seem simple (and actually kind of is pretty simple), but not so much when you try to Google a solution.  Mostly you come up with services that promise to give you code to include on your site that they generate for you once you join, pay, or give an email address.  Most of the ones I tried were pretty crappy.  And then there was that lovely link to their site at the bottom that you coudn’t disable.  ICK!!!

Finally I went to RSS2HTML.  It had come up on my Google results but I hadn’t really checked it out.  Well after some pretty crappy include code I got over myself and downloaded the free version.  It claimed to be simple but the documentation was kind of confusing.  The main point of confusion was assuming you needed an xml file to point to for the script to work.  WordPress provides a URL but not necessarily an XML file for that purpose.  I  finally put the url into the rss2html.php file for the xml location:
$XMLfilename = “http://kevware.wordpress.com/feed/”;

Uploaded everything, then loaded the template file in my web browser from my live site (none of this works when using localhost… at least it didn’t for me).  Voila!  There it all was as I had hoped.  Kind of jacked up looking and badly in need of styles and formatting, but it was all there.

There are only three files you need to make this work:  the template file, the parser file, and the rss2html.php file.  If you make your template a php file, you can add it as an include to your php page.  I wouldn’t recommend that though.  Because of how it pulls from the rss2html file it can really jack up your existing page when previewed in DW or even when posted.  I got around this issue by putting it into an iframe on my homepage.  And that solved the rendering problems.  Once I got it up and running (and tweaked as much as needed to look the way I wanted) I felt silly for how much time I had put into hunting down other “easier” solutions.  This one may not have seemed easy at first when I went to their home page, but it turned out to be exactly what I wanted… and needed!

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Verification *

This site uses Akismet to reduce spam. Learn how your comment data is processed.