wp_redirect acting weird. requires die() afterward?
Posted
by Joseph Carrington
on Stack Overflow
See other posts from Stack Overflow
or by Joseph Carrington
Published on 2010-04-10T21:55:34Z
Indexed on
2010/04/10
22:03 UTC
Read the original article
Hit count: 330
I am writing a wordpress plugin that redirects the user. for some reason, wp_redirect does not work as think it should, namely: it seems not to redirect the user at all, unless I put a die command in directly after. here is some code:
switch($_GET['wp_favorites_tax'])
{
case 'post_tag':
wp_redirect(add_query_arg('tag', $_GET['wp_favorites_term'], get_bloginfo('url')));
die();
break;
case 'category':
wp_redirect(add_query_arg('cat', $_GET['wp_favorites_term'], get_bloginfo('url')));
die();
break;
default:
wp_redirect(get_bloginfo('url'));
die();
}
It seems really strange to me that I should have to tell my script to die so that the redirect can work. I have also tried a basic
header("Location: $location);
to similar ends, ie: it still requires the die() in order to work. really perplexing me. Thanks.
© Stack Overflow or respective owner