Possible to use conditionals within add_feed() callback?

I’m using add_feed() to create some custom feeds but calls to is_singular(), is_home() etc… just don’t seem to work within the callback. Is there a workaround for this?

Example code:

Read More
add_action( 'init', 'my_init' );
function my_init() {    
    add_feed( 'new_feed', 'feed_output' );
}

function feed_output() {
    if ( is_home() )
        load_template( '/path/to/feed/home/template.php' );
    else
        load_template( '/path/to/feed/template.php' );
}

I’ve added a trac ticket for this too.

Related posts

Leave a Reply

1 comment

  1. You can only use conditional tags after the posts_selection action hook has run.

    According to the codex article on add_feed it should be called with the init action, which runs before. Now I don’t know when and how you run it, because you don’t say so in the above example, but I’d assume you do it before posts_selection – that would explain your dilemma anyway.