[wp-hackers] is_feed() broken ?

Austin Matzko if.website at gmail.com
Fri Jan 25 14:01:12 GMT 2008


On Jan 25, 2008 7:55 AM, Ozh <ozh at planetozh.com> wrote:
> I don't get how is_feed() is supposed to work. Consider the following
> in a plugin:
>
> add_action('init', 'breakfeed');
> function breakfeed() {
>         if (is_feed()) die('moo');
> }
>
> I wasn't able to get the breakfeed() function triggered:
> site.com/feed/, site.com/wp-feed.php etc work as usual.
>
> What am I missing ?

"init" is too early.  Try "template_redirect" for the action hook.

At "init," everything is loaded, but the actual parsing of the feed
query---when WP_Query sets is_feed to true---hasn't taken place yet.
That will happen when the wp function is called.


More information about the wp-hackers mailing list