Answer the question
In order to leave comments, you need to log in
Advanced custom fields - how to change content on button click?
There are three colors to choose from (implemented by buttons), grey, pink and white (each button has a value with a color name). How can I change the content of the block using Advanced custom fields if gray color is selected? But when clicking on white, the content changed to a different value?
Example
<p>Выберите цвет:</p>
<?php
// переменные
$colors = get_field('cveta');
// проверка и вывод кнопок с цветами
if( $colors ): ?>
<div class="choice-color">
<?php foreach( $colors as $color ): ?>
<button class="<?php echo $color; ?>" value="<?php echo $color; ?>"></button>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="output">
//Если нажимаем на серую кнопку
//Показать блок 1
//Если нажимаем на серебрянную кнопку
//Показать блок 2, скрыв остальные блоки
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question