How to use is_author in feeds? (7 posts)

  1. pampfelimetten
    Posted 6 years ago #

    Hi dear community,

    I try to get the following to work:

    function xxx_filter_cat()
    	if (is_author()) query_posts("cat=4");
    	if (is_front_page()) query_posts("cat=2,3");
    add_action('rss2_head', 'xxx_filter_cat');

    It should alter the rss2 feed, depending if it should generated for the general homepage, or for a single user.

    But: It doesn't work at all - is_author and all the others is_* functions I tried always trigger false. is_feed works, but well, doesn't help me very much.

    So: How can I determine the request inside the rss feed?

    Thanks in advance!

  2. pampfelimetten
    Posted 6 years ago #

    nobody can help me?

  3. pampfelimetten
    Posted 6 years ago #

  4. Mark / t31os

    Posted 6 years ago #

    is_author and is_XXX type functions (generally) check to see if there is a set query var..

    So author would be a query like.


    Depending on your permalink settings.


  5. pampfelimetten
    Posted 6 years ago #

    Hi t31os_

    thanks for your answer!

    The problem is: They do work at:

    but NOT at:


    Which, in my humble opinion is a bug.

    I can alter nearly every part of wp, and I think I should be able to alter the feeds of authors, categories, etc... independent to each other.

  6. Mark / t31os

    Posted 6 years ago #

    Is this on a test site or one i can see?

    If you're using a local install, print out your rewrite rules so you can check they exist..

    <pre><?php print_r( $wp_rewrite->rules ); ?></pre>

    localhost/author/admin/feed/ - works as expected for me..
    localhost/author/testuser/feed/ - also works

    Perhaps you should try a pre_get_posts filter for managing the categories on feeds though..

  7. pampfelimetten
    Posted 6 years ago #

    I wrote a workaround, also see trac ticket:

    function xxx_filter_rss()
    	$uri= explode("/", $_SERVER['REQUEST_URI']);
    	if ($uri[1]=="author") {
    		global $wpdb;
     		$name = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename='".$uri[2]."'");
    	} else {
    add_action('rss2_head', 'xxx_filter_rss');

    I still think that there should be a better way to do stuff like that.

Topic Closed

This topic has been closed to new replies.

About this Topic