这有什么作用,虽然有效?

I found this line on a Wordpress template and I'm not sure about how it works. Anyone with any ideas?

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Note: I'm not wondering about the methods. My question is about the syntax.

<?php if(conditional) : while(conditional) : method; ?>

This block of code is a part of wordpress called 'the loop' (more info here). This is where wordpress loops through posts and displays them on the page

That code as such is invalid, this is just the beginning of the alternative control structure syntax. The full syntax must include the respective end blocks:

if (/* .. */) :
    while (/* .. */) :
        /* .. */;
    endwhile;
endif;

You can write all that on one line, as the author did, instead of indenting it. Whether that makes it more readable or not is a matter of opinion; I'd say it does not improve readability at all. But then, Wordpress is not exactly a great example of great PHP practices (IMO).