Create an RSS Shortcode

Although I had two small self-hosted WordPress blogs before Egyptological, it’s the first set of sites I have built properly. One thing I have learned is the power of shortcodes. I like the ability to embed functionality into pages rather than use widgets. One I created, and which is used extensively on the Portal is an RSS feed reader.

I’ll post up the code in a week or two once I am sure it’s thoroughly debugged but the useage is like this:

[‌simple‌-feed feed=”http://feeds.feedburner.com/NewsFromTheValleyOfTheKings”]

That will display the items from that feed.  In practice, of course, we want more control than that.  So there are load of options that can be specified.  I have listed them below with a default for each – the option only needs to be specified if you want something other than the default.

number = 10 – the number of items to display

show = ‘content’ – show the content or the description

show_title = ‘no’ – change to yes to change to show the feed title.   From version 0.2, short is available to truncate titles at (immediately before) the first : or –

post_title = ‘yes’ – change to no to change to show the feed title

words = ‘0’ – use a number (eg 20) to specify the (approximate) max number of words to show (o is unlimited)

format = ‘html’ – by default any HTML in the feed is display, use the text option to strip all tags.

feed_id = ” – optionally specify a feed id (for use in CSS)

feed_class = ” – optionally specify a feed id (for use in CSS)

before = ” – use to specify any HTML to display before the feed

after = ” = use to specify any HTML to display after the feed

(As well as posting up the code, I’ll add a chart showing the structure of the HTML output in a future article.)

For example, real usage might look something like this:

[‌simple‌-feed feed=’http://egyptology.blogspot.com/feeds/posts/default?alt=rss’ number=5 show=’content’ words=’20’  format=’text’]

Sometimes, we might not want any posts. For instance [‌simple‌-feed feed=”http://feeds.feedburner.com/Kate-Phizackerley-Business” number=o show_title=”yes”] displays [simple-feed feed=”http://feeds.feedburner.com/Kate-Phizackerley-Business” number=o show_title=”yes”]

That will need formatting sensibly of course.  If you know the name and address of the site it’s better to use them directly, but if you think they might be dynamic then sometimes this option might be valuable.