php – get_query_vars always retruns empty value
Question
I try to get this example running:
function themeslug_query_vars( $qvars ) {
$qvars[] = 'custom_query_var';
return $qvars;
}
add_filter( 'query_vars', 'themeslug_query_vars' );
$testvar = get_query_var('custom_query_var');
echo "testvar=[$testvar]";
as found on page https://developer.wordpress.org/reference/functions/get_query_var/
With my test page I can see my little testvar string but with “?custom_query_var=help” at the end of my URL my “testvar” is empty.
In my test scenario I use the original twentytwentyone theme with no plugins activated. My code is placed at the end of functions.php.
Does anybody have me an advice of how to fix this issue?
Regards
Peti
0
3 weeks
2023-01-18T10:55:16-05:00
2023-01-18T10:55:16-05:00 0 Answers
0 views
0
Leave an answer