0

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

2

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 );
    }
}
| 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 – Niraj Chauhan 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 – Niraj Chauhan 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%20Missing%20argument%201%20for%20get_category_feed_link%28%29,%20called%20in%20/home/managem3/public_html/mbas/wp-content/themes/cityguide/archive.php%20on%20line%2010%20and%20defined%20in%20%3Cb%3E/home/managem3/public_html/mbas/wp-includes/link-template.php%3C/b%3E%20on%20line%20%3Cb%3E570%3C/b%3E%3Cbr/%3E – Niraj Chauhan Jan 18 '11 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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