This Pro tutorial provides the steps to add a class or a data-<taxonomy> attribute to terms of the current post for the given taxonomy so they can be styled differently for different terms in Bricks.
Sample use case: On the Blog page set a specific background color for all "Nature" category archive labels/links and a different background color for "Flowers" category archive labels/links in the posts grid.
We will cover both static and dynamic cases wherein category-specific colors can either be set in CSS (static) or pulled from a Color-type of custom field for the categories (dynamic).
Sample HTML markups:
To display the linked terms with our custom HTML markup, we can use this dynamic tag as one of the Fields of the Posts element in a Query Loop:
This outputs the categories for the current post in the loop separated by a comma.
The function is going to be set to take 2 parameters: taxonomy (
category is the default) and separator (
, is the default).
In this example, let's use this instead so there is no separator:
Let's define a custom function that takes in the taxonomy and separator as its arguments and returns the term names linking to their archives with the taxonomy slugs as the value of the
Add the following in child theme's
functions.php or a code snippets plugin:
This is a BricksLabs Pro tutorial.
For full access login below or create your BricksLabs Pro account
Great idea, Sridhar.
Do you have any idea about how to show in a single post template an image field inside metabox taxonomy? I can’t find a solution. I’ve tried help on the bricks forum.
so you want to loop through the categories that the current post is assigned to and pull the image field for each category?
The situation is like CPT product and Taxonomy Brand. In single post I need display the logo ( published on taxonomy )
In a archive template the dynamic field is working fine, but in single-products isn’t working.
I’ll follow this tutorial in a single template as well.
yes, the tutorial I linked will work.
if so, follow https://brickslabs.com/current-posts-terms-in-bricks/.