Support Forum
Support › MB Term Meta › Category Colors Not Showing on Custom Taxonomy
Hi - I created catageory colours for a custom taxonomy as per here: https://docs.metabox.io/tutorials/style-posts-different-categories/
However, I cannot get the colour to show on any archive pages. I hoped I could get the catageory taxonomy link to show in the correct custom category color.
Even if I use the suggested code in a code block, the text does not show in the category color on an archive page.
<?php
// Getting the value:
$value = rwmb_meta( 'custom_category_background_colour', [ 'object_type' => 'term' ], get_queried_object_id() ); ?>
<div style="background-color: <?= $value ?>">
<h2>My section title</h2>
<p>My section content</p>
</div>
<?php // Displaying the selected color: ?>
<p>This is the color: <?php rwmb_the_value( 'custom_category_background_colour', [ 'object_type' => 'term' ], get_queried_object_id() ); ?>Something here</p>
Btw, I'm using Bricks Builder if that helps at all.
Many thanks.
Hello Harry,
Please export the field group to a JSON file and share it here. I will help you to check the issue.
Refer to the documentation https://docs.metabox.io/extensions/meta-box-builder/#export--import
Many thanks, here's the json.
{
"post_type": "meta-box",
"post_title": "Custom Categories Background Colours",
"post_date": "2023-08-16 13:43:24",
"post_status": "publish",
"post_content": "",
"settings": {
"object_type": "term",
"taxonomies": [
"bcb-categories",
"bcb-holidays-categories"
],
"tab_style": "",
"tab_default_active": "",
"custom_table": {
"name": ""
},
"class": "",
"prefix": "",
"text_domain": "your-text-domain",
"function_name": "your_prefix_function_name"
},
"fields": {
"color_j43ypdodekq": {
"_id": "color_j43ypdodekq",
"name": "Category Background Colour",
"id": "custom_category_background_colour",
"type": "color",
"label_description": "",
"desc": "",
"std": "",
"min_clone": "",
"max_clone": "",
"add_button": "",
"admin_columns": {
"position": {
"type": "after",
"column": "title"
},
"title": "",
"before": "",
"after": "",
"sort": false,
"link": false
},
"columns": 12,
"tooltip": {
"icon": "",
"position": "top",
"content": ""
},
"before": "",
"after": "",
"class": "",
"sanitize_callback": "",
"save_field": true
}
},
"data": [],
"meta_box": {
"title": "Custom Categories Background Colours",
"id": "bcb-categories-background-colour",
"taxonomies": [
"bcb-categories",
"bcb-holidays-categories"
],
"text_domain": "your-text-domain",
"function_name": "your_prefix_function_name",
"fields": [
{
"name": "Category Background Colour",
"id": "custom_category_background_colour",
"type": "color"
}
]
}
}
Hello,
I import the field group to my demo site and add your code to the archive template in the theme folder. It displays the category color correctly in the frontend, screenshot https://monosnap.com/file/6yeca0dk42iPDeNiw1pleuGVVTT0L1
You can try to use a default theme of WordPress, deactivate ethe builder, add the code to the archive template of the theme and recheck this issue.