[wp-hackers] Page Redirect from Shortcode

Dion Hulse (dd32) wordpress at dd32.id.au
Thu Oct 6 05:44:13 UTC 2011


Shortcodes are parsed/called at display time, by the time the shortcode
function is called, the header and some posts may/will have printed.

Your only real option is to hook in early on template_redirect (or similar)
and scan through $wp_query->posts manually looking for the shortcode, and
handling it there..

A shortcode might not be the best option for what you're trying to achieve?
what are the reasons you've gone with a shortcode?

On 6 October 2011 16:41, Claude Needham <gxxaxx at gmail.com> wrote:

> To solve a problem for my website I would like to use a shortcode with
> the ability to redirect the page depending upon the state of a cookie.
>
> Unfortunately this generates:
>
> Warning: Cannot modify header information - headers already sent by
> (output started at
>
> xxxxx/wp/wp-content/plugins/fv-wordpress-flowplayer/view/frontend-head.php:33)
> in xxxxx/wp/wp-includes/pluggable.php on line 934
>
> Is there an approach that will get me into the process early enough
> that wp_redirect() is still viable?
>
> Thanks,
> Claude Needham
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list