WordPress.org

Forums

Current Category Feed (10 posts)

  1. altp
    Member
    Posted 10 years ago #

    I want to update the link to the RSS feed on each page depending on what the current category is. Is there a way to either:

    1) Call that directly?

    2) get the current category name with the dashes already in place? (category "foo bar" has the uri "foo-bar")

    Either of these options would get me what I need.

    Mike.

  2. Cypher
    Member
    Posted 10 years ago #

    Mike,

    If you have permalinks enabled, and are using the default stucture..then categories will have the URL of:

    http://yoursite.com/archives/category/<category name>

    If you add "/feed" to that URL, you will grab the RSS feed for that particular category.

    So, on whatever page you want to put the feel, just grab the SERVER_URL or something using PHP and then append "/feed" to it..

    It should be that simple. (TM) :)

    Regards

  3. altp
    Member
    Posted 10 years ago #

    This doesn't seem to work. Most likely because by the time the PHP scripts get a whole of it, apache has already parsed it all out.

    No matter where I am on the site, request_uri is always the initial index.php ... not the actual url that was visited.

  4. altp
    Member
    Posted 10 years ago #

    Er. perhaps I should have actually ed used request_uri before responding ;-).

    works fine using that. I initially put it php_self for some reason

  5. Cypher
    Member
    Posted 10 years ago #

    Ahh yes..request_uri, that's the one I was trying to think of. I'm glad it worked for you. :)

    Regards

  6. thepete
    Member
    Posted 10 years ago #

    Thanks for this thread! It's been very helpful.

    However, I have one question for Cypher (or anyone else who knows the answer): Is there anyway to have the category description and name used in the feed as opposed to the title of your blog and blog description?

  7. soupenvy
    Member
    Posted 10 years ago #

    And if you're not using the default permalink stucture?

    - Can't seem to get a category feed with the above methods.

  8. TungPo
    Member
    Posted 10 years ago #

    http://yoursite.com/archives/category/<category name>
    If you add "/feed" to that URL, you will grab the RSS feed for that particular category.

    This works as long as a category contains 1 page. With more pages, the mod_rewritten URL for a feed looks like http://site.com/category-name/page/4/feed/. There's no feed at this address - only at http://site.com/category-name/feed/.

    How can I get the feed links on the deeper category pages to point to the .../category-name/feed/, not the unexisting .../category-name/page/number/feed/?

  9. dubsix
    Member
    Posted 9 years ago #

    This works as long as a category contains 1 page. With more pages, the mod_rewritten URL for a feed looks like site.com/category-name/page/4/feed/. There's no feed at this address - only at site.com/category-name/feed/.

    How can I get the feed links on the deeper category pages to point to the .../category-name/feed/, not the unexisting .../category-name/page/number/feed/?

    I don't suppose anyone has figured this out yet?

  10. dubsix
    Member
    Posted 9 years ago #

    I don't suppose anyone has figured this out yet?

    I finally did myself! Added this to .htaccess

    RedirectMatch /categories/(.*)/page/.*/feed/ /categories/$1/feed/

    I had to use RedirectMatch, for some reason a similar RewriteRule was not working.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags