Change page template programmatically ?

It is possible using the template_redirect hook.

Looks something like this :

 function language_redirect()
 {
      global $q_config;

      if( $q_config['lang'] == 'en' )
      {
           include( get_template_directory() . '/page-template_en.php' );
           exit;
      }
      else
      {
           include( get_template_directory() . '/page-template_de.php' );
           exit;
      }
 }
 add_action( 'template_redirect', 'language_redirect' );

Code is untested, but should look like that.

See my similar answer HERE for more help.

Leave a Comment