• I’m trying to keep the categories as nearly virtual separate blogs.

    I’m really liking word press (particularly the RSS feature) but there doesn’t seem to be a way someone can get an RSS feed for all posts in an individual category.

    I’ve searched the codex without finding it. If this feature already exists I would apprecaite a pointer. Otherwise I would like to make it a feature request.

    Thanks,

    Dewey
    [email protected]

Viewing 15 replies - 1 through 15 (of 34 total)
  • Moderator James Huff

    (@macmanx)

    You can have feeds by category in Strayhorn.

    For example to get all the RSS 2.0 feeds for the Java category from my blog use:
    https://blog.taragana.com/index.php/category/Java/feed/

    Is there a way to have the RSS feed <title> field include the name of the category or be the name of the category?

    Sure there’s a way ?? i use it on my own blog. Look here :
    https://dommiers.free.fr/wordpress/index.php/category/1914-18/feed/

    all you have to do is to insert this code in the title tag of your wp-rss2.php (in the wordpress root) file. It’s just under the channel node

    <title><?php bloginfo_rss('name'); ?><?php if (is_category()) echo " : " ?><?php echo single_cat_title(); ?></title>

    to be more clear, i put this code in my index page

    <?php
    $URL=get_settings('siteurl') . "/wp-content/themes/" . get_settings('stylesheet');
    $LinkToFeed=str_replace("//","/",$REQUEST_URI . "/feed/");
    $TheCat=single_cat_title('',false);
    ?>
    <div id="content">
    <?php if (is_category()) { /*If this is a category archive*/?>
    <h3><?php echo $TheCat; ?>
    <a href="<?php echo $LinkToFeed; ?>" title="RSS Feed"><img src="<?php echo $URL; ?>/img/xml.gif" alt="RSS Feed" title="RSS Feed for the category <?php echo $TheCat;?>"></a></h3>

    by this way i wrote the selected category (into the h3 tag) under my header, i personnalize my xml “icon” and i let the user choose if he want to suscribe to my rss feed for the selected category (not for all the site…) by clicking on the icon.

    I hope i’ve been clear, cause it’s late now and my english is really not perfect ??

    Looks perfectly understandable to me, Flegme, nice work.

    Apart from that, if you need a rss for several categories you can use this code in a plugin file:

    function feed_categories_rules(&$rules)
    {
    $rules['index.php/feed/(feed|rdf|rss|rss2|atom)/([0-9,]+)/?$'] = 'index.php?&feed=$matches[1]&cat=$matches[2]';
    $rules['index.php/(feed|rdf|rss|rss2|atom)/([0-9,]+)/?$'] = 'index.php?&feed=$matches[1]&cat=$matches[2]';
    return $rules;
    }

    add_filter('rewrite_rules_array', 'feed_categories_rules');

    The function adds a two new rules to rewrite_rules so if you use a url like: https://www.example.com/index.php/feed/rss/4,5,6 you?′ll get a feed with the content of 4,5 and 6 categories included their subcategories

    I am a newbie, and I have to questions:

    1. In Flegmes example. Can I put that code anywhere in index.php?

    2. In Dixie example. How do I create a plug-in? (i will research this topic in the forums, but just wanted to ask)

    Thanks

    Hi,

    This post:
    https://www.ads-software.com/support/topic/18679 did the trick for me.
    I think that one of the things that did it, was to turn on Permalinks, and the rest followed.

    Little patch for rss feed… i correct my script because there was a problem when you navigate on differents pages for a category so here is the “correctif” :

    <?php
    $URL=get_settings('siteurl') . "/wp-content/themes/" . get_settings('stylesheet');
    $LinkToFeed=str_replace("//","/",$REQUEST_URI . "/feed/");
    $TheCat=single_cat_title('',false);
    $pospage=strpos($LinkToFeed, "page");
    if ($pospage ==true) {
    $LinkToFeed=substr($LinkToFeed, 0, $pospage)."feed/";
    }
    ?>

    By the way, the user can “scroll” between pages and select the rss feed anywhere in it’s navigation, not only in the front page of the selected category.

    Hope this help,

    Flegme.

    nieuws

    (@nieuws)

    Isn’t there a way in WordPress itself, it automatically does the job already for recent comments per post for example.

    OK, so it can be hacked. But what I want (and am trying to hack) is to make the “implicit” RSS feed announced in the header (as link-alternative, which is what browsers subscribe to) for the archive pages for a category to be the RSS feed for that category instead of the RSS feed for the whole blog.

    OK here is what I added to the header template, if anyone’s interested.


    <?php
    if (is_category()) {
    $fullrss = get_category_rss_link(0,intval( get_query_var('cat')));
    } else {
    $full_rss = get_bloginfo_rss('rss2_url');
    };
    $rss2_url = $fullrss;
    $rss_url = $fullrss."rss/";
    $atom_url = $fullrss."atom/";
    ?>
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php echo $rss2_url; ?>" />
    <link rel="alternate" type="text/xml" title="RSS .92" href="<?php echo $rss_url; ?>" />
    <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php echo $atom_url; ?>" />

    TyskJohan, thanks, that’s really handy.

    Flegme: that looks really handy, but I couldn’t get it to work… could someone repost explaining where each bit of code goes…

    I tried implementing it in several places, but no joy. I’m not a php coder, so I need baby steps…. ??

    Thanks to anyone who can help…

    Also, any other tips on making feeds easier to access for users greatly appreciated.

    frankp, I’m afraid the code snippet I posted no longer works in WP201.

Viewing 15 replies - 1 through 15 (of 34 total)
  • The topic ‘RSS feed for each category’ is closed to new replies.