6th Dec '23
/
1 comment

Color Custom Field as Section Background Color on Category/Term Archives in Bricks

Updated on 15 Sep 2024

Looking to apply a color picker type of custom field’s value for categories/custom taxonomy terms as the background color of a hero section on the category/term archive pages in Bricks?

A term archive page for which a blue color is set:

Another term archive page for which no color is set (shows the default):

This tutorial shows how.

Step 1

Using a plugin like ACF or Meta Box, create a field group whose location is set to your category or custom taxonomy.

Add a field of Color Picker type.

Notice that we have set a default value of #333.

Step 2

Edit your categories or taxonomy terms and assign a color for each.

Step 3

Create a template of “archive” type for your category/term archive pages and edit it with Bricks.

Apply a template condition to ensure that it applies to the correct category/term archive pages.

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

{term_name}

Select the Section → STYLE → ATTRIBUTES.

Add a style attribute having this value:

background-color:{acf_service_category_color}

Replace acf_service_category_color with the dynamic tag of your custom field.

Update 1

If you use JetEngine the process is similar.

For the style attribute value type background-color: then position the cursor at the end and pick your custom field name.

Ex.:

background-color:{je_service-category_service_category_color}

where service-category is the taxonomy slug and service_category_color is the name/ID of the Colorpicker JetEngine field.

Get access to all 610 Bricks code tutorials with BricksLabs Pro

1 comment

Leave your comment

 

Related Tutorials..

Pro
ACF User Field Bricks PHP Query

ACF User Field Bricks PHP Query

In the Bricks Facebook group a user asks: my end goal was to create a set of cards that would display the Users that are…
Categories:
Pro
Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

Filtering Query Loop Posts by a Non-empty Custom Field in Bricks

This Pro tutorial shows how we can prefilter the results of a query output by a Bricks query loop to only those for which the…
Categories:
Tags:
Pro
Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

Filtering posts by a group field’s true / false field sub field value with ACF or Meta Box in Bricks

This Pro tutorial covers how posts of a Bricks query loop can be filtered to show only the ones whose true / false or checkbox…
Categories:
Tags:
Pro
Filtering ACF Relationship Query by Post Meta in Bricks

Filtering ACF Relationship Query by Post Meta in Bricks

How to filter the posts of a post type related to another post type based on the value of a True / False type ACF…
How to create parallax effects using Rellax.js in Bricks

How to create parallax effects using Rellax.js in Bricks

This tutorial provides the JS & PHP codes that can be pasted in order to create smooth parallax effects using the Rellax.js library inside Bricks…
Categories:
Pro
ACF Flexible Content Field – Layout Labels and Sub Field Labels

ACF Flexible Content Field – Layout Labels and Sub Field Labels

How to output the text of layout labels and/or sub field labels using the Flexible Content field of ACF Pro.
Categories:
ACF Checkbox Items with Custom SVG Bullets in Bricks

ACF Checkbox Items with Custom SVG Bullets in Bricks

We walk through outputting list items with SVG icons based on the choice of a ACF Checkbox field.
Categories:
Tags:
Pro
Related Services grouped by Service Categories on Single Branch Posts in Bricks

Related Services grouped by Service Categories on Single Branch Posts in Bricks

How to query ACF relationship fields on single CPT templates.
Categories: