On wordpress and ACF,
I am searching for a way to load different <div>
(one OR the other, not both)
based on the choosen content from the ACF « select » field (named « type_of_page ») when the page load.
I have two type of selector « actual » OR « archive »
that have to load two <div>
« #now » OR « #before »
<?php
if(get_field('type_of_page') == "archive")
{
//...
}
?>
<div id="now">NOW</div>
<div id="before">BEFORE</div>
How sould I release that, without loading both ?
You've pretty much got it:
<?php if( get_field( 'key' ) == 'value' ) : ?>
<div id="content-a"></div>
<?php else : ?>
<div id="content-b"></div>
<?php endif; ?>
If you are worried that content-b
will load but be hidden in cases where content-a
is desired, check the source code after viewing the page in a browser. You will see that content-b
cannot be loaded if content-a
is loaded (and vice-versa) using this logic.