Doing a site for a photographer.
She needs to be able to change the colour of the Navigation to either black or white (depending on what colour the background photo is)
Using a simple radio button
black : Black
white : White
return vale : both (array)
It’s linked to every page and category (all set up with custom taxonomies)
It works on the normal ‘pages’
It works on ‘posts’ (custom)
It works on ‘posts’ (normal WP blog)
It does NOT work on the category?
<nav id="desk"
<?php $colour = get_field('menu_colour'); ?>
class="<?php echo $colour['value']; ?>" >
Now it should show
class=”black”
OR
class=”white”
Main question is:
Why wouldn’t it work on the custom category?
Field group settings are:
Taxonomy – is equal to – pcat (custom category name)
The Radio field shows in the category and you can choose black or white, it’s just not changing on the page?
Notes: it’s not a cache issue as I can switch back and forth on other pages no problem
It’s in the header.php that is common to every page
Hi qiD
Sorry, I’m not sure I get the relevance of that code.
Could you explain how it would help my issue please.
Thanks
Dan
<?php
$colour = get_field('menu_colour');
if( !$colour ) {
$colour = 'default';
}
?>
<nav id="desk" class="<?php echo $colour; ?>">
</nav>
Hi qiD
Tried that but it still ‘sticks’ to white even when black is selected.
I tried changing it to
echo $colour[‘value’];
also tried changing it from
array (both)
to value
and using your code as it is.
very weird
As before – it works correctly on the other pages (using my code or your new code)
Yes qiD
Tried having the setting the same as yours.
Must be something else causing it.
Thanks for trying.
Where you added code – category.php ?
Please test:
print_r($color);
var_dump($color);
https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/
The topic ‘Radio button value not changing’ is closed to new replies.
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.