In WordPress site, when we are doing custom changes in theme or plugins, we may need to pass argument or variable through the WordPress URL. Here we hare going to learn how to Add query string parameter/arguments to WordPress URL.

1. For Single Value

( Using a single key and value )

$old_url = "";
$new_url = esc_url(add_query_arg( 'key', 'value', '$old_url' ));

2. For Multiple Values

( Using an associative array )

$old_url = "";
$new_url = esc_url(
                 'key1' => 'value1',
                 'key2' => 'value2',
                 'key3' => 'value3',

Note : Always use esc_url() before outputting the link because this function does not escape URLs and if output without escaping, would make the page vulnerable to XSS scripting.

  • Jexstype

    I have been exploring for a bit for any high quality articles or blog posts in this sort of area . Exploring in Yahoo I eventually stumbled upon this site. Reading this info So i’m satisfied to exhibit that I have an incredibly just right uncanny feeling I found out just what I needed. I so much for sure will make certain to don’t overlook this site and give it a look on a constant basis.