Answer the question
In order to leave comments, you need to log in
How to display the value of one custom ACF field if a value is selected in another field of type "Select" (select)?
Hello!
I use the ACF plugin to work with custom fields.
I created fields for displaying links in the page template and placed them in variables:
$gotlink_1 = get_field('mylink_1',$block_id);
$gotlink_2 = get_field('mylink_2',$block_id);
$gotlink_3 = get_field('mylink_3',$block_id);
$gotlink_4 = get_field('mylink_4',$block_id);
$gotlink_5 = get_field('mylink_5',$block_id);
$selected_link = get_field('select_link',$block_id); // поле выбор (select)
<?php if( $selected_link == 'Ссылка 1' ): ?><? echo $gotlink_1 ?><?php endif; ?>
<?php if( $selected_link == 'Ссылка 2' ): ?><? echo $gotlink_2 ?><?php endif; ?>
<?php if( $selected_link == 'Ссылка 3' ): ?><? echo $gotlink_3 ?><?php endif; ?>
<?php if( $selected_link == 'Ссылка 4' ): ?><? echo $gotlink_4 ?><?php endif; ?>
<?php if( $selected_link == 'Ссылка 5' ): ?><? echo $gotlink_5 ?><?php endif; ?>
<a href="<?php echo $main_link ?>">Перейти к просмотру</a>
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