• Hey,

    I have an ACF color picker in a group field and trying to use the restricted colors as the background color of a div.

    Any help on how I can do this?

    Everything I tried didn’t work.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Adam Walter

    (@adamwalter)

    Simple! Make a subfield in the ACF group for the background color. Use that field’s value (it will be a HEX color) in your template code and drop it into a style attribute in your div.

    That works for single posts & taxonomy archives but not on the home page archive which uses the loop.

    $terms = get_the_terms( get_queried_object_ID(), 'category' );
    
    foreach( $terms as $term ) {
    
    $background = get_field( 'post_color', $term );
    
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use color field as background colour?’ is closed to new replies.