Codeable info

RSS Feed Shortcode

Posted on by in WordPress Tutorials

WordPress shortcodes are great, you can toss some important code into the “functions.php” file and call upon it later by using a quick and simple command tag. If you’ve been following along in most of our tutorials you’ll find we use shortcode quite often, and why wouldn’t we? It makes things easier!

In the case of an RSS feed shortcode, it enables us to place feed links anywhere on our blog without sacrificing style and form. Using the method in this tutorial we can stylize a box or visual layout in our “style.css” file and then call upon the main RSS functions using simple WP shortcode.

Style The RSS Link

First things first, we need to style the RSS link because we don’t want our finished product looking too plain. The method to make our RSS link look good, and in some cases better than everyone else’s, involves editing the active themes “style.css” source file. So make sure to do a complete database backup (if you haven’t already) before continuing.

Toss this code into your “style.css” source file and customize it to your liking:

  border:2px #D5E9D5 solid;

Basically this creates an item called “.rss-box” that can be customized and called upon at a later time. Any styling you add or change in the “style.css” file will reflect on the displayed item. So be sure to make all proper edits and changes in this code segment (it’s ok to come back after we’re done).

RSS Function Code

Now it’s time to add in the inner workings of the RSS feed system, as usual the following code should be implemented into the active themes “functions.php” source file (don’t break any existing code):

function subscribeRss() {
    return '<div class="rss-box"><a href="INSERT-RSS-FEED-URL-HERE"> Hey you, subscribe to my RSS feeds!</a></div>';
add_shortcode('subscribe', 'subscribeRss');

Before saving the source file make sure to add the RSS feed URL for your WordPress enabled blog or site in the “INSERT-RSS-FEED-URL-HERE” section. Also the message that appears with the RSS feed link can be customized by editing the “Subscribe to my RSS feeds!” section. Personally we recommend throwing in a sharp and witty statement but to each his own.

We ♥ Shortcode

See how simple that was! If you didn’t know already WPMods has fallen in love with WordPress shortcode, and we have no doubt that you will too.

Shortcodes make adding new features and implementing new objects and code fun and simple. In the case of the RSS feed link above, it allowed us to create a stylish and professional looking RSS link in less than ten minutes!

What more could you ask for? Well… except for a trillion dollars.

Comments Closed

Codeable info