I don't understand some wordpress theme code

2 replies
Code:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
 ##Html Code##
<?php endif; ?>
what does it mean?

I think
if(have_post()) <--- It mean "If I have post,it return value "true" so
While(have_posts()) will be do but it return value "false" the_post() will do.

I see some clip "how to make wordpress theme" but i don't understand this code what does is mean?
#code #theme #understand #wordpress
  • Profile picture of the author temmokan
    The mentioned PHP code snippet isn't correct (returns errors when being parsed), the correct could look like this

    Code:
    <?php if(have_posts()) : while(have_posts()) : the_post(); endwhile; ?> 
    ##Html Code## 
    <?php endif; ?>
    ("endwhile" closing statement was missing). I.e., if have_posts() returns true, do in loop the_post() while it's still true, after that insert the enclosed HTML.
    {{ DiscussionBoard.errors[8238178].message }}
    • Profile picture of the author khongpak
      Originally Posted by temmokan View Post

      The mentioned PHP code snippet isn't correct (returns errors when being parsed), the correct could look like this

      Code:
      <?php if(have_posts()) : while(have_posts()) : the_post(); endwhile; ?> 
      ##Html Code## 
      <?php endif; ?>
      ("endwhile" closing statement was missing). I.e., if have_posts() returns true, do in loop the_post() while it's still true, after that insert the enclosed HTML.
      Thank you
      {{ DiscussionBoard.errors[8239091].message }}

Trending Topics