The Query String control allows you to conditionally show or hide blocks based on query strings. What is a “query string” you might ask?
Well, you undoubtedly have come across them while browsing the internet and they appear after the
? in URLs. For example:
The orange text is a query string, which is made up of a parameter and a value. You can also concatenate multiple strings using the
& symbol. Query strings are used for all manner of things, notably for tracking and marketing purposes.
How to Use
Enabling the Query String Control
Click on any block in the Block Editor and navigate to the Visibility panel. You will notice an ellipsis icon in the Controls Toolbar. See the screenshot below. Click on the ellipsis and all the available controls will appear. Select “Query String” and the Query String control panel will be added to the block.
Now that the control panel has been added, you can configure block visibility based on URL query strings. Note that in order for the Query String control to work properly, only add one query string per line in each textbox. The following three formats are accepted.
param=value – Query parameter with a specific value.
param=* – Query parameter with a wildcard value. (i.e. the value could be anything)
param – Query parameter with no value. Operates the same as a wildcard value.
Below is an overview of how each field works.
Required Queries (Any)
The block will only be shown if if the URL has at least one of the provided query strings.
Required Queries (All)
The block will only be shown if the URL, at a minimum, has all of the provided query strings. It could have more.
Required Queries (Not)
The block will be hidden whenever at least one of the provided query strings is present in the URL. The “Not” queries take precedent over all other queries.
How to Disable
If you would like to disable the Query String control at the block level, simply click on the ellipsis icon in the “Controls” bar and deselect it. That said, if you don’t think you will need this control on your website at all, it can be disabled globally in the Visibility Control Settings in the Integrations section.
Note that if this control is disabled globally, any blocks that are actively being hidden by the Query String control will become visible again.