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...
TBWritten byThomas Bourdin1 min read
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:
The principle of the hook remains useful, but the administration screens and WordPress APIs have evolved since the publication. Test the code in a staging environment with the exact version of the site's core, theme, and plugins.
Save the files and the database before making any changes.
Control user capabilities, nonces, input validation, and output escaping.
Place customizations in a dedicated plugin or a child theme to preserve updates.