0

I have this code for my 2 custom rss feeds:

add_action( 'init', 'custom_feeds' );
function custom_feeds()
{
    foreach( array( 'custom1', 'custom2' ) as $name )
    {
        add_feed( $name, 
            function() use ( $name )
            {
                get_template_part( 'rss', $name );  
            }
        );
    }
}

function feedFilter($query) {
    if ($query->is_feed) {
        $query->set('cat', '7');
        $query->set('posts_per_page','5');
    }
    return $query;
}
add_filter('pre_get_posts','feedFilter');

I wanted to put filter on custom2 only, like filter the feed by category 7 only; But my filter is affecting all the rss feeds.

1 Answer 1

1

As you can see from the source is_feed takes a parameter, so you should be able to restrict the query by using $query->is_feed('custom_rss2').

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.