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
Sorry, I added message to another window.
Soon I’ll help you.
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)
Please check my settings https://d.pr/FREE/CIhgG4
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/