<?php if ( have_posts() ) : ?>

by 3 replies
4
How does this work? there is no "if while"
#programming #&gt #&ltphp #> #<php #haveposts
  • Banned
    I would think it's a ;
  • PHP has an option to replace the opening and closing braces using the ":" (colon) operator when you use the if loop. In that case, the opening braces is replaced with the ":", and the closing braces is replaced with an "endif;". For example,

    Code:
    if(have_posts()){
    //do something here
    }
    can be replaced by,

    Code:
    if(have_posts():
    //do something here
    endif;
    If you scroll down the code on the page you're looking at, you are bound to see a closing "endif" somewhere (either on that page, or a subsequent included page).
    • [ 1 ] Thanks
  • What do you mean by:

Next Topics on Trending Feed