Forums

Single category RSS Feed URL outside Loop (7 posts)

  1. ericr23
    Member
    Posted 2 years ago #

    Suppose you want to provide a link to the RSS feed at the head of a category archive page. How would you generate that automatically?

    If not the feed link, then the URL of the specific category, to which "feed/rss2/" could be added. This can be done in The Loop with the_category().

    Or the category slug, which can be prefixed by "www.domain.com/blogdirectory/category/" and followed by "feed/rss2/". This can be done in The Loop with get_the_category().

    Outside of The Loop, I get the name of the category with single_cat_title(), but that returns the name, not the slug (e.g., Rhode Island instead of rhode-island).

  2. whooami
    Member
    Posted 2 years ago #

  3. ericr23
    Member
    Posted 2 years ago #

    Nice plug-in, but it doesn't appear to do what I'm asking, which is, e.g., if the Rhode Island category page is displayed, a link for the Rhode Island category RSS feed is provided.

    I came up with the following. The first is what I will use. The second provides the link with the full category hierarchy.

    <a href="http://www.wind-watch.org/news/category/
    <?php
    $theCategory = single_cat_title("",false);
    $theCategorySlug = $wpdb->get_var("SELECT category_nicename FROM $wpdb->categories WHERE cat_name='$theCategory'");
    print $theCategorySlug;
    ?>
    /feed/rss2/"><font "style="background:#FF6600;color:#FFFFFF;font-size:92%;" "><b>&nbsp;RSS2&nbsp;</b></font> for this category</a>
    <a href="
    <?php
    $theCategory = single_cat_title("",false);
    $theCategoryID = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$theCategory'");
    $theCategoryLink = get_category_link($theCategoryID);
    print $theCategoryLink;
    ?>
    feed/rss2/"><font "style="background:#FF6600;color:#FFFFFF;font-size:92%;" "><b>&nbsp;RSS2&nbsp;</b></font> for this category</a>
  4. whooami
    Member
    Posted 2 years ago #

    yes it does..

    customizable set of options that enable users to create category links next to their corresponding feed links. Other new features include optional category post counts and custom RSS icons for feed links.

  5. MrBrian
    Member
    Posted 1 year ago #

    Or you could do this:
    ">

  6. MrBrian
    Member
    Posted 1 year ago #

    Blah, forgot code tags:
    http://www.yourdomain.com/?feed=rss2&cat=<?php echo get_query_var('cat'); ?>

  7. wondermade
    Member
    Posted 1 year ago #

    $category = get_the_category();
    echo "feed://blogs.northlandchurch.net/blog/" . strtolower(str_replace(" ","-",$category[0]->cat_name)) . "/feed";

    That worked for me.

Topic Closed

This topic has been closed to new replies.

About this Topic