I need help to resolve this php syntax error, unexpected 'endwhile'(T_ENDWHILE)

<?php get_header (); ?>
      if (have_posts ());
           while (have_posts ()); the_post (); ?>
      <h1><? php  the_title();  ?></h1>
      <p><? php  the_content();  ?></p>
<? php  endwhile ;
<?php get footer(); ?>

It’s difficult to read your code as it’s not between ticks (```) but it looks as though your while statement ends in a semicolon rather than a colon, viz

while (have_posts ()):
  the_post ();
1 Like

Thanks but am having the same issue with the endif statement after the endwhile statement now?

Same problem. You have a semicolon instead of a colon at the end of your if statement.

1 Like

Thanks it works.

1 Like

Good-oh! :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.