Support » Fixing WordPress » How to use is_author in feeds?

  • 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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • nobody can help me?

    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.

    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.

    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..

    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.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to use is_author in feeds?’ is closed to new replies.