php - Page Not Found in title of WordPress page on template_redirect using include() -


i've added custom rewrite rule wordpress site so:

add_rewrite_rule( 'register/bronze', 'index.php?action=register&type=2', 'top' ); 

then within template_redirect action, check against action querystring variable , load include so:

$action = get_query_var( 'action' );  if( $action == "register" ) {     include( bg_file_path . '/templates/register-brand.php' );     exit; } 

this works fine , custom template displayed, however, page title appears "page not found | site name".

is there way can set page title custom template? i'm trying avoid setting these pages wordpress page since they're fundamental running of site, don't want 1 of admins change page settings or delete page entirely.

any appreciated.

wordpress overwriting title because still throwing 404 (you can verify using firebug).

wordpress typically throw 404s when including files in template redirect.

you need reset header using code :

global $wp_query; $wp_query->is_404 = false; status_header( '200' ); //if status_header doesn't work, try header("http/1.1 200 ok")  //now reset 404, can proceed include $action = get_query_var( 'action' );      if( $action == "register" ) {         include( bg_file_path . '/templates/register-brand.php' );         exit;     } 

this should reset status header , allow title of included file appear normally. no need javascript :)


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -