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

2
  • 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 Commented Dec 6, 2018 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 Commented Dec 7, 2018 at 0:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.