I’m engaged on a customized template and displaying some posts (of customized sort) teasers on it. Within the template PHP file, I need to retrieve a URL question variable (if handed) and show the content material accordingly. The URL with the question variable is generated from the identical template web page. If I strive one thing like this to generate URL:
<?php echo esc_url( add_query_arg( 'custom_var', '2' ) ); ?>
and in features.php:
operate add_custom_query_var($vars) {
$vars[] = "custom_var";
return $vars;
}
add_filter('query_vars', 'add_custom_query_var');
and go to http://www.instance.com/template_page_url/?custom_var=xyz
, it work as anticipated and I can get the worth utilizing get_query_var
operate. The issue is that once I exchange this custom_var
with web page
or p
, these variables are faraway from the URL robotically when the web page is loaded. Briefly a URL like:
http://www.instance.com/template_page_url/?web page=xyz
is redirected to:
http://www.instance.com/template_page_url/
Can we not use these variables in customized templates? Or is there any means to take action? And I’m not on the lookout for pagination, this web page
variable is supposed for completely customized logic. I do know the WP_Query
class additionally use web page
variable and I’m certain there’s something conflicting. Any assist could be appreciated.