[wp-hackers] 'init' and 'wp' actions calls fail on functions.php

Austin Matzko austin at ilfilosofo.com
Fri May 21 13:02:24 UTC 2010


On Fri, May 21, 2010 at 7:53 AM, Vinicius Massuchetto
<viniciusandre at gmail.com> wrote:
> Would be something like:
>
> add_action ( 'init', 'link_redirect' );
>
> function link_redirect () {
>
>        echo 'lala';
>
> /*      global $wp_query;
>
>        $id = $wp_query->post->ID;
>
>        if ( $url = get_post_meta( $id, 'redirect', true ))
>
>                wp_redirect($url);
> */
> }

"init" is too soon for the post property of $wp_query to be populated.
 You probably want "template_redirect" instead.


More information about the wp-hackers mailing list