I'm writing a Wordpress plugin, and based on certain circumstances, I want to redirect to a different page, but the redirect never happens. headers_sent() returns false. I'm using the pre_get_posts hook. Here is a small snippet:
function test_redirect()
{
header("Location: http://www.cnn.com/");
}
add_action('pre_get_posts', 'test_redirect');
The redirect never happens, and no errors are reported on the page or in the error log. Why can't I redirect?