I've got the following code:
<?php if(get_field('wide_or_small_navigation') == "wide") { ?>
Do something here
<?php } ?>
I want to make it so that it works like this:
<?php if(get_field('wide_or_small_navigation') == "small") { ?>
Do something like <?php the_field('test'); ?>
else if
Do something else like <?php the_field('test'); ?>
else if
<?php } ?>
So basically, if wide is chosen do one thing, if small is chosen do another and if neither is chosen, the final item.
Andrea P answers:
something like this?
<?php if( get_field('wide_or_small_navigation') == "small") : ?>
<?php // do something if it's small ?>
<?php elseif ( get_field('wide_or_small_navigation') == "wide" ) : ?>
<?php // do something if it's wide ?>
<?php else : ?>
<?php // do something if it's neither of the two ?>
<?php endif; ?>
Kyler Boudreau comments:
Andrea - worked beautifully! Thank you.
isp_charlie answers:
<?php if(get_field('wide_or_small_navigation') == "small") { ?>
Do something like <?php the_field('test'); ?>
<?php } elseif( //condition ){ ?>
Do something else like <?php the_field('test'); ?>
<?php } else { ?>
Do something else like <?php the_field('test'); ?>
<?php } ?>
Navjot Singh answers:
You can go like
<?php if (get_field('wide_or_small_navigation') == "small") { ?>
Do something like <?php the_field('test'); } ?>
<?php elseif (get_field('wide_or_small_navigation') == "wide") { ?>
Do something like <?php the_field('test'); } ?>
<?php else { ?>
Do something
<?php } ?>
dimadin answers:
Something like this? Or I didn't understand what is a problem.
<?php
$value = get_field('wide_or_small_navigation');
if($value== "wide") { ?>
<?php } elseif ($value == "small") { ?>
<?php } else {?>
<?php } ?>