Wednesday, January 18, 2023
HomeWordPress Developmentphp - get_query_vars at all times retruns empty worth

php – get_query_vars at all times retruns empty worth


I attempt to get this instance operating:

operate 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 discovered on web page https://developer.wordpress.org/reference/features/get_query_var/

With my check web page I can see my little testvar string however with “?custom_query_var=assist” on the finish of my URL my “testvar” is empty.

In my check situation I take advantage of the unique twentytwentyone theme with no plugins activated. My code is positioned on the finish of features.php.

Does anyone have me an recommendation of methods to repair this subject?

Regards
Peti

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments