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:http://www.wpbeginner.com/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 filecategory.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.
1 | <?php |
2 | $category = get_category( get_query_var( 'cat' ) ); |
3 |
4 | if ( ! empty ( $category ) ) |
5 |
6 | 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>' ; |
7 | ?> |
By adding the above code, 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:
1 | < img src = "http://example.com/location/to/rss/icon.png" width = "48" height = "48" alt = "Subscribe" /> |
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:01 | <?php |
02 | $category = get_category( get_query_var( 'cat' ) ); |
03 |
04 | if ( ! empty ( $category ) ) |
05 |
06 | 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> |
07 |
08 |
09 | <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> |
10 |
11 |
12 | <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> |
13 |
14 | </p></div>'; |
15 | ?> |
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.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.
0 comments:
Post a Comment