Conditional Output on the First Page of Archives in Bricks

A user asks:

if i have wg. category page with list of items – i have 3 pages. i want to show some text only on first page.

its possible to make it?

We can check the value of get_query_var( 'paged' ) in a dynamic data condition to output an element only on the first page of paginated archives in Bricks.

For example,

example.com/category/nature/:

example.com/category/nature/page/2:

Step 1

Whitelist the get_query_var function.

Ex.:

<?php 

add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'get_query_var'
  ];
} );

You should also add other functions (native or custom) being used in your Bricks instance besides get_query_var. This can be checked at Bricks → Settings → Custom code by clicking the Code review button.

More info on whitelisting can be found here.

Step 2

Edit your archive template with Bricks.

Apply a dynamic data condition on the element that you wish to be output only on the first page like this:

{echo:get_query_var(paged)}

Get access to all 526 Bricks code tutorials with BricksLabs Pro

1 comment

Leave your comment

 

Related Tutorials..

Is WooCommerce Cart Empty Condition in Bricks

Is WooCommerce Cart Empty Condition in Bricks

Looking to conditionally render an element depending on whether the user's cart is empty or not when using WooCommerce? and use it with a Dynamic…
Pro
ACF Repeater sub field value dynamic data condition in Bricks

ACF Repeater sub field value dynamic data condition in Bricks

This Pro tutorial provides the steps to output an element on single posts (can be of any post type) only if a specified ACF (Pro)…
Pro
Showing a Popup conditionally in Bricks based on Query Parameter

Showing a Popup conditionally in Bricks based on Query Parameter

Here's two ways a Bricks Popup can be shown on page load depending on URL parameter value.
Categories:
Tags:
Create A Customizable AJAX Add To Cart Button In Bricks Builder

Create A Customizable AJAX Add To Cart Button In Bricks Builder

In Bricks, you can simply create an Add To Cart button from a dynamic data / function {woo_add_to_cart}. This button supports AJAX as well if…
Pro
User Role Condition in Bricks

User Role Condition in Bricks

This Pro tutorial provides the steps to conditionally output elements depending on the currently logged-in user's role. Step 1 Create a section Template having the…
Categories:
Pro
Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Checking if the current Page/Post has Children i.e. is a Parent in Bricks

Shows how we can check whether the current Page or Post (of any hierarchical post type) is a parent
Categories: