Title: Modify button URL based on query string paramters
Last modified: September 27, 2025

---

# Modify button URL based on query string paramters

 *  Resolved [csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * (@csdsubscriber)
 * [8 months, 2 weeks ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/)
 * I’m wondering if this plugin would allow me to modify the URL a button opens 
   based on the query string parameters passed to the page?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [davidjo1983](https://wordpress.org/support/users/davidjo1983/)
 * (@davidjo1983)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18663405)
 * [@csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * Yes, it is possible. It depends on some factors, such as which page builder you
   are using and how the button is set up (feasibility comes down to whether the
   button’s link field accepts shortcodes or not).
 * If it doesn’t work out of the box, it shouldn’t be complicated to create the 
   button in a way that does—using HTML, for example.
 * As for pulling the query string into the link, you have two options:
    1. **Query String DKI shortcode** – You pick a parameter, and the value of that
       parameter is generated automatically.
       [https://www.if-so.com/query-string-dki-shortcode/](https://www.if-so.com/query-string-dki-shortcode/)
    2. **Trigger with a Page URL condition** – For example, _if the page URL contains`?
       your\_parameter=value`_, you can set up the link manually according to your 
       needs when the condition is met.
       [https://www.if-so.com/help/documentation/page_url/](https://www.if-so.com/help/documentation/page_url/)
 *  Thread Starter [csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * (@csdsubscriber)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18664683)
 * Came here to respond to a reply I received via email, but I don’t see that reply
   here. Anyway, let me describe the scenerios I’m after.
 * I’d like to be able to receive to the same page different parameters like so:
   
   [https://mydomain.com/mywebpage](https://mydomain.com/mywebpage)[https://mydomain.com/mywebpage](https://mydomain.com/mywebpage)/
   123[https://mydomain.com/mywebpage](https://mydomain.com/mywebpage)/234[https://mydomain.com/mywebpage](https://mydomain.com/mywebpage)/
   345
 * Based on these I’d like to do two things. One is aim a text link to different
   urls based on the received parameter. The second is to set the URL a button clicks
   through to also to different urls.
 * So for the first scenario it might be like this:
   [https://mydomain.com/apage](https://mydomain.com/apage)
   123 = [https://somedomain.com/somepage](https://somedomain.com/somepage)234 =
   [https://someotherdomain/anotherpage](https://someotherdomain/anotherpage)345
   = [https://yetanotherdomain/yetanotherpage](https://yetanotherdomain/yetanotherpage)
   Will want to be able to do that same for a button, either a Gutenburg button 
   or HTML based if I must.
 * Is there a link that would show me how to do these. Or could someone provide 
   me with a response that shows how?
 *  [davidjo1983](https://wordpress.org/support/users/davidjo1983/)
 * (@davidjo1983)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18665751)
 * It’s important to distinguish between a **permalink** and a **parameter**.
 * In your example ([https://mydomain.com/mywebpage/123](https://mydomain.com/mywebpage/123)),
   the number is a permalink.
   A parameter, on the other hand, is an addition to 
   the URL that doesn’t change the base address. A parameter consists of a key and
   a value, and looks like this:
 * `example.com?parameter=value`
 * Or, when chaining multiple parameters:
 * `example.com?parameter=value&parameter2=value2`
 * There are several possible solutions, and all of them may be relevant in your
   case. To guide you toward the best option, it’s important to:
    1. Understand how many different parameters or permalinks you will need.
    2. Determine whether you can use parameters instead of permalinks.
 *  Thread Starter [csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * (@csdsubscriber)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18666032)
 * Yes parameters will work fine. Just one for a give page.
 * Given that can you share with me how I would implement a solution based on the
   examples I gave, replacing the permalink approach with a parameter for the ending
   different values?
 *  [davidjo1983](https://wordpress.org/support/users/davidjo1983/)
 * (@davidjo1983)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18666379)
 * If you only have a single parameter per page, the easiest solution is to duplicate
   the Gutenberg button and set an If-So condition for each one:
    1. **First button:** If → Page URL → **does not contain** → your parameter name
       and value
    2. **Second button:** If → Page URL →** contains** → your parameter name and value
 * For each button, you can then set the relevant link.
 * ![](https://wordpress.org/bdeed567-57dc-4e99-92f5-478e388efe76)
 *  Thread Starter [csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * (@csdsubscriber)
 * [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18667603)
 * Yes initially I moved toward that. Ultimately I ended up coding a shortcode that
   sets the values of the button based on the query parameter.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Modify button URL based on query string paramters’ is closed to new replies.

 * ![](https://ps.w.org/if-so/assets/icon-256x256.gif?rev=2633132)
 * [If-So Dynamic Content – Elementor & All Page Builders Personalization](https://wordpress.org/plugins/if-so/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/if-so/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/if-so/)
 * [Active Topics](https://wordpress.org/support/plugin/if-so/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/if-so/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/if-so/reviews/)

## Tags

 * [Query String](https://wordpress.org/support/topic-tag/query-string/)

 * 9 replies
 * 2 participants
 * Last reply from: [csdsubscriber](https://wordpress.org/support/users/csdsubscriber/)
 * Last activity: [8 months, 1 week ago](https://wordpress.org/support/topic/modify-button-url-based-on-query-string-paramters/#post-18667603)
 * Status: resolved