WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 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?

share|improve this question

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:

if ( have_posts() )
    while( have_posts() )

I prefer the second style, most code editors enable automatic folding with it, so I can close parts I don't need to see.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.