How to Allow Users to Subscribe to Categories in WordPress

94

WordPress comes with built-in taxonomies, categories and tags, that allows you to organize your content. Almost every WordPress user has used categories and tags to sort their content, but most users don’t know that categories, tags, and custom taxonomies each have their own RSS feeds (What is RSS?). Why is that useful? Well, these topic specific RSS feeds allow your users to only subscribe to the content they are most interested in. In this article, we will show you how to allow users to subscribe to categories in WordPress.

Category Specific RSS Feed in WordPress

By default, WordPress enables topic specific RSS feed for each category, tag, and custom taxonomy. Most smart browsers will detect and display the RSS feed URL of the page. You can access the category specific RSS feed by simply adding /feed/ to the end of category URL. For example:

/category/wp-tutorials/feed/

Now the easiest way to allow users to subscribe to categories in WordPress is by letting them know about it. You can add a category RSS feed link on each category page. You can also also add other subscription options such as feedly, and bloglines. Last but certainly not the least, you can allow them to subscribe to category via email. Let’s look at all of these options in details.

Adding a RSS Subscription Link on Category Pages

Lets start with adding a simple RSS subscription link on category pages. 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 archive.php. If you don’t see either of those, then there is a strong chance 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 does not have a category.php file, but it has an archive.php file, then create a new file called category.php and paste all the code from archive.php in it. Once you are done, then paste the above code in it.

By adding the above code, you will be able to see a subscribe link on your category archive page like so:

Category Subscription Link

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:

Category Subscription Icon

Adding Other Subscription Options for Categories in WordPress

While most users who use a RSS reader already have the browser extension installed, 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 Bloglines. 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 category.php file:

  <?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/home#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="http://www.bloglines.com/sub/' . get_category_feed_link( $category->cat_ID ) . '" title="Subscribe via Bloglines" rel="nofollow"><img src="http://example.com/location/to/bloglines/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 Bloglines, so they can subscribe to the category feed. This is how it looked on our test site:

Category Subscription Additional Icons

Adding Email Subscription for Categories in WordPress

When users look at our sidebar subscription option, they think each of those checkboxes are categories. While they are not categories, the concept of adding category specific subscription is very similar.

WPBeginner Subscription Checkboxes

To add email subscription for categories, you would need to utilize a third-party email subscription service like MailChimp or Aweber. Both of these companies have a feature called RSS to Email. You would need to create a list segment aka groups, and then use those in combination with RSS to Email feature to accomplish email subscription for WordPress categories.

We have created already written a guide on how to create a daily and weekly newsletter in WordPress which highlights all the same concepts. Please check that out to learn how to create groups and setup RSS to Email campaign.

The only difference is that you will have to create a RSS to Email campaign and Groups for each individual category. This is why it is very important that you are using categories the right way.

Next, simply copy and paste your form code on your category pages using the same method as the codes above.

There is so much more you can do with your category RSS feeds. See our tutorial on how to add content in your WordPress RSS feeds and totally manipulate them.

We hope that this article helped you in adding subscription options for your WordPress categories. If you have any questions or suggestions, then please let us know by leaving a comment below.

Social Media Auto Publish Powered By : XYZScripts.com