We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

Tutorials
More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsWordPressOther

How to Pass Value in WordPress URL

By default WordPress is not designed to pass values over the URL’s. But this does not mean you can not add this functionality manually by editing WordPress theme functions file.

Follow These Steps to to Pass Value in WordPress URL

Start with opening current theme functions.php file which is located “wp-content/themes/theme-name/” directory.

After opening it, place the following code inside the file:

1
2
3
4
5
6
7
add_filter('query_vars', 'parameter_queryvars' );
 
function parameter_queryvars( $qvars )
{
$qvars[] = 'refid';
return $qvars;
}

Save and close the file. Now to use the newly implemented code place the following lines of code in the template page:

1
2
3
4
5
global $wp_query;
if (isset($wp_query->query_vars['refid']))
{
print $wp_query->query_vars['refid'];
}

Please note: replace ‘refid’ with variable name which should be passed in the WordPress URL.

Rate this Tutorial:
One CommentLeave a Comment
  1. jaydeep

    Awesome article. Will you please keep it updated every time so it will help me in future.
    Thanks for sharing with us..!!

    Reply

    Other (182)

    Popular Keywords