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

  • Please show the code where you "query the var in another page". And explaining what you're trying to achieve will also help alot understanding your problem – kero Dec 6 '18 at 14:50
  • 2
    Very silly mistake on my part, sorry: I was trying to access a non-existing papers variable instead of 'papers' query var – Det Dec 7 '18 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.