Show Block using URL Query Strings

Available in Conditional Blocks Pro

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.

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

  1. Make sure Conditional Blocks Pro is installed, then select a block.
  2. Open the Condition Builder and add the Query String condition to the block.
  3. Write the query strings that should trigger the block to display. You can write the partial string if needed.
Screenshot of using query strings to conditionally show WordPress block content.

Setup Example

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 doc-reader=true

Additional notes

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.

Creative Examples

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 ?sucesss=true.

If you have any other creatives examples or use cases do let us know!