Hi, Im trying to find some way to make the checkboxes that I have created and “translate” them in to colors (images maybe). I think it has to be done in the .php files but I I don’t know wich one, maybe with default value ??
If someone could help me it would be great!
If there’s another topic/post like this I’m sorry, I haven’t found anything like this.
For eg. I created red green and black and I want that in the website you see the color not the word, i think that this may be done with images. But I don’t know how to do it.
I couldn’t make it work.
I tried everything, but most of the times my “color section” disapeard.
I have to make this work.. i there any other way with ACF to creat the color section of a product?
I don’t understand what you are asking.
Perhaps you could provide the code you are using?
Can you be specific as to what is and isn’t working?
Have you done any debugging?
Can you confirm he data is saved?
Can you confirm the global $post is correct when you use the get_field function?
in the post.php;
<p><?php the_field(‘colors’); ?></p>
I have tried:
1. in the default value box in the edit Custom Fields
<div style=”color: <?php the_field(‘color’); ?>”>
<p>I will take on the color chosen!</p>
2. in the meta_box_options.php
‘type’ => ‘checkbox’,
‘name’ => ‘white[hide_on_screen]’,
‘value’ => $white[‘hide_on_screen’],
‘choices’ => array(
‘the_content’ => __(“<?php ?>”,’acf’),
‘excerpt’ => __(“Excerpt”),
‘custom_fields’ => __(“Custom Fields”),
Nothing works, I don’t know where to put the code.
What is this (I don’t understand why you have pasted this code):
<?php do_action(‘acf/create_field’, array( ‘type’ => ‘checkbox’, ‘name’ => ‘white[hide_on_screen]‘, ‘value’ => $white['hide_on_screen'], ‘choices’ => array( ‘the_content’ => __(“<?php ?>”,’acf’), ‘excerpt’ => __(“Excerpt”), ‘custom_fields’ => __(“Custom Fields”), … ) )); ?>
As for you original question. Have you checked the page source (html) to actually see what is rendered. You may find that all you need to do is add a ‘#’ before the value for it to be a correct CSS color?
Hi, sorry but I don’t know what HTML page source you are refering to. If you could point out the root it would be grat. Thanks
Hi! I haven’t been able to render any color, I have tried everything ( but i’m guessing that I haven’t been doing it right) the thing is that I have tried to make it work in the php with in the plugin, and my theme, I have even tried to do it with images so I wouldn’t mess up in the code of the color.
When you wrote the first code I tried to change the color on the field group editing; I have read all the documentation available, and I can’t solve this.. 🙁
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
© 2019 Advanced Custom Fields. Subscribe