Would you like to allow your visitors to subscribe to individual tags or custom taxonomies?
When you offer a separate RSS feed for each taxonomy, your visitors can subscribe to the topics they are most interested in.
In this article, we will show you how to add RSS subscriptions for your tags and custom taxonomy archives.
Why Let Users Subscribe to Tags & Custom Taxonomies?
You might want to add RSS subscription to your tags and custom taxonomies. Then your website visitors can be notified when you publish a new blog post they might be interested in.
Each tag and custom taxonomy has its own feed URL. All you have to do is add /feed/ at the end of the URL. Here’s an example:
But most of your visitors won’t know how to find and subscribe to these feeds. Let’s take a look at how to add an RSS subscription link on tags and custom taxonomy archives.
Adding RSS Subscription Link on Tag Archives
We’ll start by adding a simple RSS subscription link to your tag archive pages.
To do this, you need to add code to your website files. If you haven’t done this before, then see our guide on how to paste code snippets from the web into WordPress.
The first thing you need to do is go inside your theme’s folder and find the file
tag.php. If you don’t see that file, then look for
Now, if your theme has a tag.php file, then simply add the following code right before the loop.
$tag_id = get_query_var('tag_id'); echo '<div class="tag-feed"><p><a href="' . get_tag_feed_link( $tag_id) . '" title="Subscribe to this tag" rel="nofollow">Subscribe</a></p></div>'; ?>
If your theme does not have a tag.php file but does have an archive.php file, then you need to create a new file called tag.php and paste all the code from archive.php into it. Once you are done, then paste the above code into it.
Note: If your theme doesn’t include tag.php or archive.php, then you’re probably using a WordPress theme framework and will have to create tag.php manually. A good starting point for learning how to create archive files is our guide on how to create custom archive pages in WordPress.
When you visit your website, you will be able to see a subscribe link on your tag archive pages. Here’s a screenshot from our demo website.
This code simply adds a link with the anchor text ‘Subscribe’ to the template. You can add an RSS icon instead of text if you prefer. All you have to do is replace the ‘Subscribe’ text with an image URL like so:
<img src="http://example.com/location/to/rss/icon.png" width="48" height="48" alt="Subscribe" />
Here’s a screenshot of a tag archive on our demo website once we modified the code.
Adding RSS Subscription Link on Custom Taxonomy Archives
We can do the same thing for custom taxonomy archives.
You need to go inside your theme’s folder and look for a file with a name like
For example, if you have a custom taxonomy called ‘Topics’, then you need to look for a file called
You then need to edit the file and paste the following code above the loop:
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo '<div class="topic-feed"><p><a href="' . get_term_feed_link($term->term_id, topics, $feed) . '" title="Subscribe to this topic" rel="nofollow">Subscribe</a></p></div>'; ?>
If you don’t have a custom taxonomy template, then create a new file and name it as we described above. You should copy and paste the contents of your archive.php file into it, then add the code snippet above.
If you’d like to use an RSS icon instead of text, then simply replace the ‘Subscribe’ text with an image tag just as we did in the section above.
We hope this tutorial helped you learn how to add an RSS subscription for tags and custom taxonomy archives.
You may also want to learn how to improve your website’s SEO, or check out our list of 30 proven ways to make money blogging with WordPress.