Support

Account

Home Forums General Issues ACF Color Picker, how?

Solving

ACF Color Picker, how?

  • Hi,
    I’m trying to work with ACF color picker with no success.
    i have created a custom field with color picket type for a certain CPT, created a post and chose the relevant color.
    now i dont understand where do i implement the code to control the class for this element?
    wordpress editor doesnt support php so its not possible to insert in the editor. so i have inserted to Header.php file the following code:

    <style type="text/css">
    .special-color {
        background-color: <?php the_field('color'); ?>;
    }
    </style>
    

    and then tried to use the class like this:
    <div class="special-color">Something here...</div>
    but it returns empty.

    what am i doing wrong? what is the correct way to use it?
    will appreciate a little guidance here.
    thanks in advance!

  • obviously Inline doesn’t work for me as well
    <div style="background-color:<?php the_field('color'); ?>">Something here...</div>

  • <div style=”background-color:<?php $post = get_post(page_id); ?><?php the_field(‘field_name’); ?>”>Something here…</div>

    *replace page id with the id, where you created the backend ‘select color’
    ** replace field name with the field you created in acf for color picker

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.