Search code examples
phphtmlwordpressparse-error

Html does parsing error in my index.php (wordpress theme)


I am building my own wordpress theme. I'm not new to the html and pages related stuff but never did line of coding for php. I wanted to move on more complex cms - wordpress. Now I cant see why but my page throws out parsing errors for some reason.

Parse error: syntax error, unexpected ... on line ##

Here is part of my code including html in php:

     <?php

     if (have_posts()) :
        while (have_posts()) : the_post();

        <h2>Title here</h2> /* says error is on this line */

        endwhile;

        else :
            echo '<p>No content found</p>'

        endif; /* also error is on this line */

     ?>

I'm using dreamweaver but that’s not key for solving this I guess.


Solution

  • <?php
    
         if (have_posts()) :
            while (have_posts()) : the_post();
    ?>
            <h2>Title here</h2> /* says error is on this line */
    <?php
            endwhile;
    
            else :
                echo '<p>No content found</p>'
    
            endif; /* also error is on this line */
    
         ?>
    

    This will help you....