SimpleRSSEmbed – my first WordPress plugin

Ok, I’ve been doing all sorts of things with WordPress for a while now, but oddly enough, I never actually wrote a plugin (although, in retrospect, I did a lot of template hacks that probably would have been easier to do as plugins). Anyway, I needed a plugin for a blog I was working on that would allow me to display the summary of N number of blog posts from another blog. There seem to be plenty of existing plugins that do this, however most of them are either horrible code (both HTML and PHP), or they don’t work with Atom feeds that don’t have descriptions. I wanted something very simple, with very clean output that would ‘just work’™. So, after trying about a dozen of them, I decided to just write my own (which turned out to be insanely easy). If I would have started down that path at first, I probably would have been done sooner.

So, if anyone is interested in this very simple plugin, here it is. Of course, it’s GPL. I expect I’ll be adding more features to it as I need, but for now this does exactly what I want with very little code to maintain.

Documentation

Download

You can get the current version from here: simplerssembed.zip

Installation

Put the contents of simpleressembed.zip into your wp-contents/plugins directory, and unzip it. This should give you a directory called ‘simpleressembed’ which has 3 things in it:

  • an empty directory called ‘cache’
  • a file called readme.txt
  • a file called simplerssembed.php

Make sure that the cache directory is writeable by your web server, or whatever user that will be executing the php scripts. The safest way (on *nix system) is to do the following (assuming that the process runs as the user ‘apache’:

[root@ simplerssembed]# chown apache: cache [root@ simplerssembed]# chmod 755 cache

Then go to the plugins tool in your WP dashboard, and activate the plugin.

Using the plugin

Once the plugin is activated, you can embed RSS feeds with the following shortcode:

[simplerssembed rssfeed='http://wordpress.org/news/feed/' rssitems='5' rsscssclass="rssfeeditem" rssdateformat="j F Y" rsslinktarget="_new"]

Parameters

The currently defined parameters are as follows:

rssfeed -> URI of the RSS feed rssitems -> The number of items to display rssmaxdescription -> The maximum number of summary characters to display rsscssclass -> The class name to give the containing <div> (per item) rsslinktarget -> The target attribute for the link to the post rsscacheduration -> The duration (in seconds) of the cache rssdateformat -> The data format (see PHP's date function)

Default values

The default values for the above parameters are:

rssfeed => 'http://wordpress.org/news/feed/' rssitems => '5' rssmaxdescription => '400' rsscssclass => 'rssitem' rsslinktarget => '_self' rsscacheduration => '3600' rssdateformat => 'j F Y | g:i a'

Example output:

This is output from the actual code above:

WordPress 6.0 “Arturo”

Say hello to “Arturo” and WordPress 6.0, inspired by Grammy-winning jazz musician, Arturo O’Farrill. With nearly 1,000 enhancements and bug fixes, the second major release of 2022 is here. Download it now! As of today, WordPress powers more than 42% of websites worldwide.

Posted on 24 May 2022

WordPress 6.0 Release Candidate 3 (RC3) Now Available for Testing

WordPress 6.0 Release Candidate 3 is now available for testing! You can download and help test RC3 in three ways. 6.0 is planned for general release on May 24, 2022.

Posted on 17 May 2022

WP Briefing: Episode 31: Open Source & Accessibility– Celebrating Global Accessibility Awareness Day With Guest Joe Devon

In the thirty-first episode of the WordPress Briefing, GAAD Co-Founder Joe Devon joins WordPress Executive Director Josepha Haden Chomphosy to discuss Global Accessibility Awareness Day and the role of open source in accessibility. Have a question you’d like answered? You can submit them to wpbriefing@wordpress.org, either written or as a voice recording. Credits Guest: Joe […]

Posted on 16 May 2022

WordPress 6.0 Release Candidate 2 (RC2) Now Available for Testing

WordPress 6.0 Release Candidate 2 is now available for testing! You can download and help test RC2 in three ways. You can also help translate WordPress to 100+ languages.

Posted on 10 May 2022

The Month in WordPress – April 2022

This past month saw a lot of preparation work for WordPress 6.0, due to release on 24 May 2022. This major release brings exciting improvements – read on to find out more about the latest happenings in the WordPress project. WordPress 6.0 Release Candidate 1 The first release candidate (RC1) for WordPress 6.0 is now […]

Posted on 5 May 2022

Leave a Reply

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