Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to add a RSS link on my website archive-pages, which means, Suppose I am on page http://mbas.in/location/mba-in-usa/ then on this page, I will be having a RSS LINK named link, when I click on this link, it should redirect me to http://mbas.in/location/mba-in-usa/feed

When anyone navigates through my archive-pages, they will get RSS FEED OF THAT PAGE just by clicking one link,

for this I tried the following code

<a href="<?php get_permalink(); ?>/feed">RSS feed of this page</a>

but I am not getting that, instead its giving me http://mbas.in/feed

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I made a mess of this in comments, so will start from scratch.

The feed links for archive pages are usually only outputted for browser detection by feed_links_extra().

From looking at its source there is number of different function to get link for the archive pages:

  • get_category_feed_link( $cat_id );
  • get_tag_feed_link( $tag_id );
  • get_term_feed_link( $term_id, $taxonomy ) (this one I found separately, not currently used in automatic feed links).

So catch-all archive feed link that will work for any taxonomy (including categories and terms) can be built like this:

function archive_feed_link() {

    if( is_archive() ) {

        global $wp_query;

        $taxonomy = $wp_query->get_queried_object();

        return get_term_feed_link( $taxonomy->term_id, $taxonomy->taxonomy );
    }
}
share|improve this answer
    
OK, I tried that also, but instead of giving me that archives-page feed link, it is giving me that archives page first post feed link, You can check the output on this page mbas.in/location/mba-in-usa Just above the google ad, see this link RSS feed of this page –  ntechi Jan 18 '11 at 9:35
    
Ah missed that, if it's archive than permalink makes no sense. Tried the_feed_link('feed'); or echo get_feed_link();? –  Rarst Jan 18 '11 at 9:53
    
@Rarst I tried it, but its giving me the homepages feed, even for echo get_feed_link, that is also returning homepages feed url –  ntechi Jan 18 '11 at 10:32
    
@ntechi sorry, looked at the wrong function. Try get_category_feed_link, only works for categories, there is analogue for tags get_tag_feed_link(). –  Rarst Jan 18 '11 at 10:36
    
@Rarst both I tried, its returning me with some weird URL check this http://mbas.in/location/mba-in-usa/%3Cbr%20/%3E%20%3Cb%3EWarning%3C/b%3E:%20%20‌​Missing%20argument%201%20for%20get_category_feed_link%28%29,%20called%20in%20/hom‌​e/managem3/public_html/mbas/wp-content/themes/cityguide/archive.php%20on%20line%2‌​010%20and%20defined%20in%20%3Cb%3E/home/managem3/public_html/mbas/wp-includes/lin‌​k-template.php%3C/b%3E%20on%20line%20%3Cb%3E570%3C/b%3E%3Cbr/%3E –  ntechi Jan 18 '11 at 10:45
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.