Discuss your project
Wordpress Front

WordPress: Override a template when a variable is present in the URL

In very rare cases, one might need to override the default template (although it's a bit dirty to do that).In the functions.php file, add the following code: function wpa_overload_template( $template ) { if( isset( $_GET['parameter'] ) ) { $template = loc...

In very rare cases, one might need to override the default template (although it's a bit dirty to do that).

In the functions.php file, add the following code:

function wpa_overload_template( $template ) {

if( isset( $_GET['parameter'] ) ) {

$template = locate_template('template-overload.php', false );
}

return $template;
}
add_filter( 'template_include', 'wpa_overload_template' );

Share this article