You are here:Home » WordPress » Add RSS Feed link to Wordpress

Add RSS Feed link to Wordpress

When you have a WordPress site you can assign different posts to categories, this allows you to group your posts together.
For example on this site I have created categories for tutorials and snippets, so if people are looking to create a complete feature you can look in the tutorials category, but if you just want some useful coding tips you can just in the snippets section.
When you create a category you are then able to navigate to this category to view all the posts which are grouped in the category.

When you view a certain category WordPress will display this content using a number of files, which are displayed in the category hierarchy of:
  • category-slug.php
  • category-ID.php
  • category.php
  • archive.php
  • index.php
First WordPress will check to see if you have a file in your theme folder names category-{category-slug}.php, if this exists then it will use this to display your category content. If this doesn't exist then it will search for a file called category-{ID}.php, then category.php, then archive.php, the finally the index.php.
I normally create a category.php file to show the category content useless I want a certain category to look different than all the others.

Add A Category Feed For Certain Category

rss feed

There maybe some categories which are more popular than others, for example you might have a freebie category where you post about free products on each post. This is a perfect candidate for someone to subscribe to just this category RSS feed.
Luckily in WordPress it will create an RSS feed for each category and they make it very easy to create a link to this RSS feed.
First open up your category.php file and add the following code to the top of your content.
<?php
     $category = get_category();
?>
<a href="<?php echo get_category_feed_link( $category[0]->cat_ID ); ?>">Subscribe to the <?php echo $category[0]->name; ?> category RSS feed</a>

0 comments:

Post a Comment