Category Drilldown in Bricks

This Pro tutorial provides the steps for showing child categories if the current category has children or posts, if otherwise on category archives when using Bricks.

Step 1

Add an image-type of custom field for setting up an image for the categories.

We are using ACF in this example.

Edit the categories and select/upload an image for each.

Step 2

Create a template named, say, "Category" of type Archive.

Edit it with Bricks.

Apply it to categories.

When we are done, the structure would look something like this:

If you'd like to import the template from our test site instead of building it yourself or for reference, it can be found near the end of this tutorial. You'd still need to add a couple of custom PHP functions mentioned in the steps below.

Add a Section and inside its Container, a h1 Heading having

{term_name}

Add a Basic Text or a Text link element and set its text to "← Parent Category".

Set its link to be dynamic and

{echo:bl_get_parent_category_url}

We also want to ensure that this element gets output only if the current category has a parent.

Set a dynamic condition like this:

Next, define the custom function bl_get_parent_category_url that we used above.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro