Would you like to allow visitors to your WordPress site to subscribe to individual categories?
When you offer a separate RSS feed for each category, your visitors can subscribe to the topics they are most interested in.
In this article, we’ll show you how to allow users to subscribe to individual categories in WordPress.
Why Allow Users to Subscribe to Categories in WordPress?
For example, a news website might have categories for their articles filed under News, Opinion, Weather, and Sports.
Luckily, WordPress automatically creates an RSS feed for each category on your site by adding
/feed/ at the end of the category page URL.
For instance, if you had a category called ‘News’ with a URL like this:
Then its RSS feed would be located at the following URL:
But most of your visitors won’t know how to find and subscribe to these feeds. Let’s have a look at how to make it easy for users to subscribe to your WordPress categories.
Adding RSS Subscription Link on Category Pages
We’ll start by adding a simple RSS subscription link to your category pages.
To do this, you need to add code to your website files, and we don’t recommend this for beginners. 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
category.php. If you don’t see category.php, then look for
If you don’t see either of those, then it’s likely that you are using a WordPress theme framework, and this article will not be as helpful for you.
Now, if your theme has a category.php file, then simply add the following code wherever you want to display the subscription link. We would recommend adding it right before the loop.
<?php $category = get_category( get_query_var('cat') ); if ( ! empty( $category ) ) echo '<div class="category-feed"><p><a href="' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe to this category" rel="nofollow">Subscribe</a></p></div>'; ?>
If your theme has an archive.php file but does not have a category.php file, then you need to create a new file called category.php and paste all the code from archive.php into it. Once you are done, then paste the above code into it.
Once you’ve added the code snippet, you will be able to see a subscribe link on your category archive page like so:
This code simply adds a link with the anchor text ‘Subscribe’ to the template. You can get fancy by adding 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">
An example subscription icon would look like this:
Adding Other Subscription Options for Categories in WordPress
Most of your visitors who use an RSS reader will already have installed the service’s browser extension for easily adding new feeds. But it can never hurt to add familiar icons to ease the process.
For the sake of example, we will add buttons for two popular web based RSS reader apps, Feedly and Inoreader. You can use the same technique to add other services if you like.
Below is the sample code that you would need to add to your theme’s
<?php $category = get_category( get_query_var('cat') ); if ( ! empty( $category ) ) echo '<div class="category-feed"><p>Subcribe via: <a href="' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe to this category" rel="nofollow"><img src="http://example.com/location/to/rss/icon.png" width="32" height="32" alt="Subscribe" /></a> <a href="http://www.feedly.com/i/subscription/feed/' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe via Feedly" rel="nofollow"><img src="http://example.com/location/to/feedly/icon.png" width="32" height="32" alt="Subscribe" /></a> <a href="https://www.inoreader.com/?add_feed=' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe via Inoreader" rel="nofollow"><img src="http://example.com/location/to/inoreader/icon.png" width="32" height="32" alt="Subscribe" /></a> </p></div>'; ?>
As you can see, we have modified the category feed links for the last two icons. The first icon still points to your original RSS feed, but the second and third icon takes the users to Feedly and Inoreader, so they can subscribe to the category feed.
This is how it looks on our test site:
Adding Email Subscription for Categories in WordPress
Many users are not familiar with RSS and will feel more comfortable with an email subscription to your website.
To add email subscription for categories, you would need to utilize a third-party email marketing service. We recommend using something like Constant Contact or Sendinblue because they offer a feature called RSS to Email.
Once you choose an email marketing service, you need to create an email list and set up an email campaign.
To collect subscribers, we recommend using OptinMonster to build newsletter signup forms.
You can use it to create opt-in forms and easily add category check boxes without writing any code.
After that, you can follow our step by step guide on how to notify subscribers of new posts.
The difference is that you will have to create an RSS to Email campaign and group for each individual category. This is why it is very important that you are using categories the right way.
We hope this tutorial helped you learn how to allow users to subscribe to categories in WordPress.
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.