functions - template_redirect action only firing if logged in

add_action('template_redirect', 'add_header_redirect', 0, 0);function add_header_redirect(){if( is_

add_action('template_redirect', 'add_header_redirect', 0, 0);
function add_header_redirect(){
    if( is_page(array(8, 'testimonials', 'Testimonials')) ){
        $default_testimonial = get_permalink( 19 );
        header("Location: $default_testimonial");
    }
}

this code is in my functions.php file and ONLY works when I am logged into WP. I want all users who go to /testimonials to be redirected. what's going on?

add_action('template_redirect', 'add_header_redirect', 0, 0);
function add_header_redirect(){
    if( is_page(array(8, 'testimonials', 'Testimonials')) ){
        $default_testimonial = get_permalink( 19 );
        header("Location: $default_testimonial");
    }
}

this code is in my functions.php file and ONLY works when I am logged into WP. I want all users who go to /testimonials to be redirected. what's going on?

Share Improve this question asked Jul 5, 2012 at 23:34 zackzack 2211 gold badge3 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The problem was with WP-Super-Cache plugin. When I was logged in, it wasn't serving me a cached file, so my template redirect was being executed. Not sure if this is a known liability with WP-Super-Cache.

My solution was to make a template for page-testimonials.php where I set up my PHP redirect. After flushing the cache, the redirect works.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745043855a4607974.html

相关推荐

  • functions - template_redirect action only firing if logged in

    add_action('template_redirect', 'add_header_redirect', 0, 0);function add_header_redirect(){if( is_

    7小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信