One of our most requested features has been to show Gutenberg blocks based on http query strings. You can apply the query string condition to any block or group block.
This is a premium condition to change the visibility of WordPress content using Conditional Blocks Pro.
(P.S This block is a Reusable Block + Conditions. It won’t be shown if you’ve purchased Conditional Blocks Pro)
Query Strings also known as URL Variables, are information that can be passed to the server/website to create dynamic content. Query strings are located at the end of the URL and begin with a
? Have a look at the example below.
How to use Query String Conditions on Blocks
- Make sure Conditional Blocks Pro is installed, then select a block.
- Open the Condition Builder and add the Query String condition to the block.
- Write the query strings that should trigger the block to display. You can write the partial string if needed.
Let’s say we want to display a special promotion for users for reading the docs. And we want the URL to look like this https://conditionalblocks.com/pricing/?doc-reader=true
Our query string condition on the promotion block should look like this
You only need to write in the query string pattern, not the URL itself. In the above example
/pricing/ never needs to be included in the pattern.
Confirmation pages by Form plugins
You can use Query String conditions to easily apply dynamic content to confirmation pages of form plugins like Gravity Forms. Often these types of plugins will add their own query strings to confirmation pages that will allow you to display Gutenberg blocks based on the data. The query string may look like this
If you have any other creatives examples or use cases do let us know!