Okay so I kind of understand that ternary operators work like
condition ? TRUE : FALSE
However I’m looking a simple loop to get my posts that I have
<?php if (have_posts()) :
while(have_posts()): the_post();
the_content();
endwhile;
endif;
?>
The question I have is where is the ? in this syntax. Why is the :
used when according to the
condition ? TRUE : FALSE
Whatever comes after the semicolon is when that statement (like have_posts())
is FALSE?
The double colon in this case is part of the alternative syntax for control structures.
That’s not the ternary operator.
You could also write instead:
I prefer the second style, most code editors enable automatic folding with it, so I can close parts I don’t need to see.