This Pro tutorial provides the steps to register a custom function that returns true or false depending on whether the current page URL has specific query parameters in Bricks.
For example only if the URL has fname, lname and email URL parameters like this:
https://bricks.local/query-variables-test/?fname=sri&lname=kat&email=srikat@gmail.com
should a Section be output.
Step 1
Let’s add our custom query vars, fname, lname and email in this example to the array of public query variables available to WP_Query.
Add this in your child theme’s functions.php or a code snippets plugin:
add_filter( 'query_vars', 'bl_query_vars' );
function bl_query_vars( $qvars ) {
array_push( $qvars, 'fname', 'lname', 'email' );
return $qvars;
}
Next define a custom function that returns true or false like this:
function bl_url_has_query_vars() {
$fname = get_query_var( 'fname' );
$lname = get_query_var( 'lname' );
$email = get_query_var( 'email' );
return $fname && $lname && $email;
}
If the URL has all the 3 query variables then the above function will return true, otherwise false.
Step 2
Edit your Page or Bricks template with Bricks.
For the element you want to output if the URL has all the 3 query variables, say a Section set up this Dynamic data condition:
{echo:bl_url_has_query_vars} == 1

If you want to check if all the query variables are NOT present, change the == in the condition to !=.
Reference
https://developer.wordpress.org/reference/functions/get_query_var/