How to Add RSS Feed Subscription Link in WordPress Tag and Category Pages

Serving the RSS feed subscription for your blog readers is good idea to engage them reading your new articles. By default WordPress has it’s own technique for showing the RSS feed link at the address bar for your blog feed and for the individual category, tag  page feed as well.

Tip: Add Extra Widget Section In WordPress Blog.

But from the readers perspective, bloggers love to place and highlight the RSS feed subscription in the website body. It is not worth to say that how to place the blog RSS feed link in your blog page like at the header, sidebar or footer.

But what if you want to place a RSS Feed link in Category or Tag pages to serve the individual feeds? Visit Tech-Tips-Geek feature post tag page.

You can see the RSS subscription link for the Feature tag. So whenever a post will be tagged with “Feature”, the subscriber will get the post by his feed reader application. The same scenario happens for the categories. Let us see how to serve the RSS feeds to readers for each category or tags from their corresponding pages.

At first keep a backup of the archive.php template from your theme folder. Now open it with notepad or WordPress editor.

For category feeds

Find out the line or some thing like this

/* If this is a category archive */ if (is_category()) { <h1>Archive for the &#8216; single_cat_title(); &#8217; Category</h1> }

Now ad the following lines after that

$cat = get_query_var('cat'); $current_cat = get_category($cat); echo'<div class="category-feed">'; echo'<div class="right-feed">'; echo '<img src="';echo 'http://yourimagesource/filename.gif';echo '"/>'; echo '<a href="';echo bloginfo('url');echo '/category/';echo $current_cat->slug;echo '/feed/';echo '">';echo 'Subscribe to ';echo single_cat_title();echo ' Category Posts';echo '</a>'; echo '</div>'; echo '</div>';

Note: Use the php query syntax wisely. See the examples below:

For Tag feeds

For tag feeds apply the same procedure. Find out the line or some thing like

/* If this is a tag archive */ } elseif( is_tag() ) {
<h1>Posts Tagged &#8216; single_tag_title(); &#8217;</h1>

Add the following code below that

 echo'<div class="tag-feed">'; echo'<div class="right-feed">'; echo '<img src=';echo '"http://yourimagesource/filename.gif';echo '"/>';
echo '<a href="';echo get_tag_link($tag_id);echo 'feed/';echo '">';echo 'Subscribe to ';echo single_tag_title();echo ' Tag Posts';echo '</a>';
echo '</div>'; echo '</div>';

Example:

Now add some CSS properties for the tag-feed and right-feed classes. For instance

 .tag-feed, .category-feed{background:none repeat scroll 0 0 #EFF7FD;border:1px solid #CCCCCC;font-size:12px;font-weight:bold; height:30px;padding:12px 3px 4px 10px;width:600px;margin-top:30px} .tag-feed,.category-feed a{color:#DF4400;letter-spacing:0.06em;margin-left:5px;} .tag-feed,.category-feed a:hover{text-decoration:underline} .right-feed{float:right;margin-right:10px}

You are done! Let me know if you face any problem with your theme template. I’ll get back to you with your solution.

* Update: There were some bugs with the previous codes. We’ve fixed them and updated the codes. Now it should work properly.

5 Readers posted their valuable comments on the article - How to Add RSS Feed Subscription Link in WordPress Tag and Category Pages
  1. Kimi

    Thanks for this!

    Actually a category RSS in wordpress can be reached on /category/catname/feed

    Same goes with the tag isn’t it?

    Thanks for sharing Tanmay!

  2. Tanmay

    Yes Kimi, you can distinguish the tag feeds also by the same way. But giving the feed link in each individual category and tag pages manually is not possible. Here this simple code helps. Thanks.

  3. Shabnam Sultan

    I will give it a try :).

  4. Anish KS

    Cool tip, will try this. will post the result.

  5. Whitny Karver

    It is very interesting for me to read that article. Thanks for it. I like such topics and anything connected to them. I definitely want to read a bit more on that blog soon.

Leave a Reply

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