Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Code
  2. Creative Coding

Tips to Customize and Optimize Your Blog's Feed

Read Time:9 minsLanguages:

When we design our blogs, we tend to forget our visitors/users who're following us with their feed readers. In this tutorial, we're going to learn to "hack" our blog's feed for a better feed reading experience for our users.

We're going to work on 10 great tips to customize our feeds. We will redesign our feed content, maybe shorten it, create functions for feed-only and blog-only content, add useful post lists like "related posts" and "more from this author", take precautions against content thieves, learn to make money with our feeds and so on.

Note: Many of these tips require skills to edit the functions.php file. Be careful while editing this file – you should be comfortable editing and debugging PHP code. Remember, always make a backup.

Tip #1 Using the Media RSS Specification

First things first: We have to use this specification to help search engines and social networks get our "featured image" (or at least the first image we used) and show it as a thumbnail.

For this very first tip, we don't have to write any code or hack our theme files. We just need to install the MediaRSS WordPress plugin. Done.

Introduced by Yahoo! in 2004, this spec allows us to state the media file(s) that we want to bring out: Podcast files, videos, and in our case the featured image. This plugin automatically adds the featured image to our feed with the MRSS-valid XML tags. If the post doesn't have a featured image, it'll scan the post for images and add the first image to our feed.

Tip #2 Placing Custom Text or Images

An incredibly useful thing to do is adding custom content to our feeds. We could place banners, copyright notices, a link to the original post... and it's easy to do, too.

Take a look at the function below:

Please take note that nearly every feed reader service will omit potentially harmful HTML tags like <script>, <embed> or <iframe>.

Adding Banners

Placing banners of your advertisers or images for your announcements could be nice since your subscribers don't see your custom ads if they don't visit your website. To add banners like these, all you have to do is place the appropriate HTML code at the top or at the bottom of your content:

Take note that we placed the $output variable before the $content variable. That means that we're placing the banners at the top of the content – according to Captain Obvious.

Adding a Copyright Notice With a Link to the Original Post

Automatic content scrapers would definitely hate this code:

It's always tempting to put these kinds of notices before the actual content but you must keep in mind that feed reader apps like Google Reader show the beginning of the feed items' text content in the list of a feed's posts. (Placing images before the content is safe, though.) This could be annoying for your subscribers:

If you don't want this to happen, you should place your notices after the content.

Tip #3 Including Custom Field Values

Let's say that you're writing a book review blog and you want to include some custom fields – that you use to store the details of the books – below the feed content. This code would be helpful:

Edit the code however you like and use it – don't forget to edit the custom field key names inside the get_post_meta functions.

Tip #4 Adding a "Related Posts" Section

There are several custom-made functions to create a related post list without using plugins but I personally like "Yet Another Related Posts Plugin (YARPP) which can automatically add a "Related Posts" section to our feed. Install the plugin, head over to its options page (Options » Related Posts (YARPP)) and adjust your settings:

Easy as that.

Tip #5 Adding a "More From This Author" Section

This could come in handy in multi-author blogs. And again, it's easy to implement:

This piece of code in our functions.php file adds a "More from John Doe" section below the post content.

Tip #6 Adding Buttons for Sharing on Social Networks

If you publish full posts in your feeds (instead of excerpts), a sensible thing would be providing your subscribers with the social sharing buttons. As we mentioned before, feed reader services omit the <script>s and <iframe>s, so we can only insert <a> links which look like share buttons.

Facebook, Twitter, Google+, and Pinterest are the hot social networks these days. So, we'll insert these networks' share buttons in our feeds:

I designed some share buttons for this tutorial but of course, you can use your own images. Just change the http://i.imgur.com/XXXXX.png links.

Please note that the "thumbnails" feature of WordPress has to be enabled in order to make this code work. If this feature isn't enabled in your theme, you'll encounter a "fatal error" in your feed. Make sure that the line below exists in your theme's functions.php file:

Tip #7 Thumbnail and Excerpt... and Nothing Else

Less is more, right?

This is my favourite function! With this code, your feed items will only consist of three elements: A left-aligned thumbnail image, the excerpt of the post and a link to the post. Nothing more.

Tip #8 Feed-Only Content and Blog-Only Content

Another simple but handy function – actually there are two functions this time:

Simply add this chunk of code to your functions.php file and you can use them like this:

Tip #9 Adding a Secret Tracking Device to Your Feeds

If you have a successful and content-rich blog and you update it regularly, chances are there will be some "content vultures" who take your feeds and update their splogs with your content automatically. You can find them when you search specific phrases of your content but it would be a lot easier if you had a unique keycode, right?

In this case, the unique code we'll use will be the hashed string of our posts' shortlinks (e.g. myblog.com/?p=1234). We'll also link it to our post and make it white so most splogs won't know that it's there. (Of course, we could link an empty image and set the alt text to the hashed string but it would be harder to track it.)

After adding this code to your functions.php file, simply subscribe to your own feed, find the hidden text at the end of your posts and search it on your favourite search engine.

Tip #10 Placing AdSense Ad Units in Your Feeds

If you have a Google AdSense account (which you should totally have) and burned your feed with Google FeedBurner (which you totally should), you might as well monetize your feeds by placing Google AdSense ads at the top or at the bottom of your feed items. When you log in to your AdSense account, it's easy as 1-2-3:

After you click on the "New feed unit" button (3), you can select your feed (which must be burned with the Google account that you're using AdSense with) and choose the ad unit type, customize the position, colors and frequency of your ads.

Anything Else?

Hope you enjoyed reading these tips. If you have your own tactics for customizing and optimizing WordPress feeds, please share them with us by leaving a comment.

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.