WAIT: ACF color picker to post categories bug

I made a color picker to my post categories. (And set up it.)
In query loop I tried to add this color to text (not background!) but its not working.

I tried it with basic text element with {post_terms_category} and built-in taxonomy elements.

  • I tried render the color in typography > color > raw/dynamic
  • And after tried Attributes > Style > color: {myacfcolorpickerfield}

In public side you can see added the attribute version, but the color: is EMPTY

image

It works fine for me in the latest version.
Are you sure that you’ve set the color? Because it doesn’t show the default color, only the specifically selected category color.

I tested in a query loop and also on the single archive page and both work great.

Hey @simplecreative,

just like @jstneti said, can you please check if the color is picked. You can also test this by outputting in basic text element (in content), and see if the color code is outputted.

Please let me know :slight_smile:

Best regards,
M

I got some more info and the issue is not on the Archive page or in a term query, but with the post query.
If I got it right, OP wants to show category names with their respective background color (ACF field) inside a post query.

Here is a solution (custom function) I came up with to achieve that (assuming there is only one category per post) if anyone is interested:

function output_term_color($post_id){
    // Return if no post_id is set
    if (!$post_id) {
        return;
    }
    // Get the first category from the post
    $term_id = get_the_category($post_id)[0]->cat_ID;

    // Get the ACF value for this term
    return get_field('color_field', 'category_' . $term_id);
}
2 Likes

Ok, I tried everything, but cant do it.
Its a simple post query (NOT ARCHIVE), where i want to coloring the categories term text.
I set up all of categories invidual colors.

I tried in typo > Raw - dynamic color
And tried Attributes > Style - color:{myafccolorfield}

But not working.

Like I wrote in my last reply, it doesn’t work in the post query. If you need it before it gets fixed, you can use my solution with a custom function (from my my last reply).

Hi Matej!
I tested is lots of, and have read jstneti comments.
Yes I found too, my request is working like a charm, if I make it in Archive page. In the simple query loop (example in frontpage) not working.

If you just output the text in Basic text element for example, is the text correct?