Custom query vars empty

admin2025-06-05  0

I have added to my child theme functions.php:

function mychildtheme_register_query_vars( $vars ) {
    $vars[] = 'papers';
    return $vars;
}
add_filter( 'query_vars', 'mychildtheme_register_query_vars' );

When I try to query the var in another page

echo (get_query_var( $papers, $default='test' ));

the result is an empty string ('test' gets echoed), even if:

 global $wp_query;
 var_dump($wp_query->query_vars);

shows the vars and their values.

Any hints ? thanks

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749123728a316564.html

最新回复(0)