Are you looking for a way to allow users to subscribe to specific categories in WordPress?
When you offer a separate RSS feed for each category, visitors can subscribe to the topics they are most interested in. This can get you more subscribers and more engagement.
In this article, we will show you how to allow users to subscribe to categories in WordPress.
Why Allow Users to Subscribe to Categories in WordPress?
Categories allow you to group your blog posts into different topics and sections. This can help visitors find interesting and relevant content, which can increase your pageviews and reduce the bounce rate while also improving the visitor experience.
For example, if you have a travel blog, then you might create categories such as Accommodation, Itineraries, and Safety Tips.
WordPress automatically creates an RSS feed for each category on your blog. In this way, visitors can subscribe to your content and get a notification every time you publish a new blog post they may be interested in.
For more information, please see our complete guide on how to use RSS in WordPress.
That said, let’s see how you can allow users to subscribe to individual categories on your WordPress website.
How to Allow Users to Subscribe to Categories in WordPress
One solution is to add a ‘Subscribe’ link to your site’s category pages. These are the pages that show all the posts within a specific category.
For example, www.example.com/category/wordpress would list all the posts in the ‘WordPress’ category.
This method requires you to add code to your WordPress website.
Often, tutorials will ask you to edit your theme files, but this can cause all kinds of common WordPress errors. In the worst-case scenario, it may even make your website inaccessible.
For that reason, we recommend using WPCode. It is the best code snippets plugin for WordPress that allows you to add custom CSS, PHP, HTML, and more to your website without putting your site at risk.
First, you will need to install and activate the free WPCode plugin. For more information, see our step-by-step guide on how to install a WordPress plugin.
Once the plugin is activated, go to Code Snippets » Add Snippet.
Here, you will see all the ready-made WPCode snippets you can add to your site. These include a snippet that allows you to completely disable comments, upload file types that WordPress doesn’t usually support, disable attachment pages, and much more.
On the next screen, just hover your mouse over the ‘Add Your Custom Code (New Snippet)’ option and click the ‘Use snippet’ button when it appears.
On the next screen, you need to type in a title for the code snippet. This is just for your reference, so you can use anything you want.
Then, open the ‘Code Type’ dropdown and choose ‘PHP Snippet’.
With that done, simply paste the following into the code editor:
<?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>';
?>
With that done, scroll to the ‘Insertion’ box and select ‘Auto Insert’ if it isn’t already selected.
You can then open the ‘Location’ dropdown and choose ‘Site Wide Header’.
This adds a ‘Subscribe’ link to every page and post across your WordPress blog.
To show the link on category pages only, scroll to the ‘Smart Conditional Logic’ section. Here, click on the ‘Enable Logic’ slider.
You can now open the ‘Conditions’ dropdown and select ‘Show’.
After that, open the next set of dropdown menus and select ‘Taxonomy Page’, ‘Is’, and ‘Category’. This will add the code to your category pages only.
With that done, it’s time to make the snippet live by scrolling to the top of the screen.
You can now click on the ‘Inactive’ toggle so it changes to ‘Active’, and then click on the ‘Save Snippet’ button.
Now, if you visit any category page, you will see the new ‘Subscribe’ link live.
This is what it looked like on our demo website.
How to Add an RSS Icon to the WordPress Category Pages
Another option is to add an RSS icon to the category pages. This may grab the visitor’s attention more than a plain link.
To add an RSS icon to your WordPress category pages, you will need to start by uploading the icon you want to use. You can use any icon you want, but you can find a logo in the PNG format over at the official RSS website.
Once you have a logo, simply upload the file to the WordPress media library. You will then need to get the image URL, as you will be using it in the next step.
With that done, create a new PHP code snippet in WPCode by following the same process described above. However, this time paste the following snippet into the WPCode editor:
<?php
$category = get_category( get_query_var('cat') );
if ( ! empty( $category ) )
echo '<div class="category-feed"><a href="' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe to this category" rel="nofollow"><img src="http://example.com/wp-content/uploads/2023/07/rss-icon.png" width="32" height="32" alt="Subscribe" /></a>
</p></div>';
?>
You’ll need to replace the http://example.com URL with the link to the RSS icon you uploaded in the previous step.
Once again, set the code to run on category pages only and then publish it by following the same process described above.
Now, if you visit any category page, you will see the RSS icon live.
Adding Other Subscription Options for Categories in WordPress
Most people who use an RSS reader will already have installed the service’s browser extension so that they can easily add new feeds. However, you can often encourage them to subscribe by adding the icons for these different services.
As an example, we will show you how to add buttons for Feedly and Inoreader, but you can use the same steps to add any other services you like.
To start, you will need to add the icons for the services you want to show. You can often find suitable icons on the service’s website or by doing a quick Google search.
For each RSS icon, you will need to make a note of its URL inside the WordPress media library.
With that done, simply create a new PHP snippet by following the same process described above with WPCode. However, this time, you will need to add the following code:
<?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://localhost:10003/wp-content/uploads/2023/07/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://localhost:10003/wp-content/uploads/2023/07/feedly.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://localhost:10003/wp-content/uploads/2023/07/inoreader.png" width="32" height="32" alt="Subscribe" /></a>
</p></div>';
?>
As before, you will need to replace each link with the image URL that you want to show on your WordPress website.
Adding Email Subscription for Categories in WordPress
Many users are not familiar with RSS, so it’s a good idea to offer email subscriptions, too.
To add email subscription for categories, you will need to use an email marketing service. We recommend Constant Contact or Brevo (formerly Sendinblue) as they offer an RSS to Email feature.
After choosing an email marketing service, you will need to create an email list and set up an email campaign.
To collect subscribers, we recommend using OptinMonster. It is the best lead-generation software that helps you convert visitors into subscribers and customers.
You can use OptinMonster to create opt-in forms with category checkboxes without writing a single line of code.
After that, you can follow our step-by-step guide on how to notify subscribers of new posts.
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 create an email newsletter or see our expert picks for the best web push notification software.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Sina says
Hi, What about if we want to have our subscribe feature by sending push notification in user browser?
Is it any plugin to do this, like MailChimp for e-mail?
WPBeginner Support says
For push notifications, you would want to take a look at our guide below:
https://www.wpbeginner.com/wp-tutorials/how-to-add-web-push-notification-to-your-wordpress-site/
Admin
Devesh Pal says
First of all, huge fan of your site, very informative, thanks for your service again!
Situation with me is my website has lets say 5 categories in total and the requirement is to display them all, now user can subscribe to any of 5 categories that he/she wish to.
What I have done so far, I have created a subscribe option for all my blogs using feeds but not specific to categories. Can you please help me in the same! Please do reply!
Many thanks for your support so far and in advance!
WPBeginner Support says
Hi Davesh,
Each category on your blog has its own RSS feed too. You can use that RSS feed and create a subscribe option just like you did for your main blog feeds. Please check out the article above for more details.
Admin
Devesh says
Okay!
So can I merge all category’s feed and display only one subscribe input which can show options for selecting either one or more/all categories?
WPBeginner Support says
Hi Devesh,
Yes. Many email services allow you to create multiple RSS to Email campaigns. You can create one for each of your category and then create a form that allows users to choose which lists they want to subscribe to.
subhash says
can you explain how to show categories
roman says
Is there a way for user to manage his subscriptions? Smth like a page or widget with all checkboxes where he could unsubscribe or subscribe to other category?
WPBeginner Staff says
Yes you can but you will have to modify the code for tags.
Kath Rowling says
can you subscribe to certain tags instead of categories?
Ahmed says
Is there a way I can make something like reddit where you subscribe to categories and view them all in a separate page?
Karen says
Hi, I’m building a site for a non profit group and they want a “back office” page/area just for committee/coordinators, so they are given a login in and password to access documents, photos forms etc – not a subscriber type of function. Can you help? cheers karen
Brenda says
Is there any way to do this with custom taxonomies?
WPBeginner Support says
Yes the basic instructions are the same, use
get_term_feed_link( $term_id, $taxonomy = 'customtaxonomyname', $feed = 'rss2' )
instead ofget_category_feed_link()
function.Admin
Swapnali says
Hieee,
This tutorial is awesome… Thanks..
Was finding very difficult to get category subscription for users. Find your tutorial and work was done in just few minutes. Thanks once again.
I want to ask one thing I am using free mailchimp, does it will cretae any problem?
Kimberly says
Nice tutorial, thanks so much.
Marc A. Flego says
First off, I absolutely love this website! Second, I have a question… What if you want to display these very same category subscribe links on your main blog page or even on a single blog post?
I assumed that it would consist of the same code being integrated into blog.php and single.php but that’s not the case – the links appear, but they do not direct correctly when clicked.
Anyone else tried this?
Editorial Staff says
Hey Marc,
The easiest solution would be to use your category URL/feed/ manually. On other pages, $category variable is not available by default. Also wp_list_categories function has the option to display all categories with feed links.
http://codex.wordpress.org/Template_Tags/wp_list_categories
Admin
Marc A. Flego says
Hmm, so there’s no variable category feed URL which can be linked to different blog posts? I would have thought that to be a fairly basic function in WordPress. If a blog post can display a category tag beside it, why can it not display a link to that feed on the same page? Maybe I’m missing something…
Badar ul islam says
This tutorial is super duper useful for people having alot of categories in their blog or website especially having more then 1 niche in their website.
Tuan Vo says
Awesome!!! Very very very very useful post
Zach Smith says
this was actually informative – not like most of what i see online. sharing