0

So, I want to add some dynamic properties to my static page.

Url of my page is mysite.com/pagename, so I've created template static-pagename.php.

I'd like to capture get argument if I go to my page by this url mysite.com/pagename?var=test.

I have tried with $_GET['var'] and get_query_var('var', 'novar'); but it doesn't work. I'm assuming that wordpress is overriding / rewriting those values, but I'm not sure how to fix that.

2

Ok. Figured it out. I had to register new query variable in my functions.php.

add_filter('query_vars', 'register_qvs' );

function register_qvs( $qvars ) {
    $qvars[] = 'my_new_var_name';
    return $qvars;
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.