Customizing Category Display in Bricks

Bricks has a post_terms_category dynamic data tag that outputs comma-separated links of categories for the current post.

It also has a Taxonomy element that outputs an unordered list of the linked terms of the specified taxonomy which can be used to show the post's categories.

What if you want to output only the top-level (not necessarily parent) categories i.e., categories that aren't child categories?

This Pro tutorial provides two ways to limit the categories to top level ones.

  • extend the Taxonomy element as a new element
  • create a custom function based on the one in Bricks and using its dynamic data tag

Custom Taxonomy element

Step 1

If the Bricks child theme is not active already, upload and activate it.





Step 2

Edit the custom-post-taxonomy.php file.


class Element_Post_Taxonomy extends Element {


This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Instant access to 390+ Bricks code tutorials with BricksLabs Pro