• Resolved techmulla

    (@techmulla)


    i am using a different index.php as compared to my home. this is my home.php.

    home.php is working fine. Now my index.php is like this.

    <?php get_header(); ?>
    
    <!-- begin container -->
    
        <div id="ygap"></div>
    
        <!-- begin sidebar -->
    
        <div id="sidebar"></div>
    
        <!-- end sidebar -->
    
        <!-- begin content -->
    
        <!-- main content -->
    
             <div id="content">
             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
             <?php endwhile; ?>
    
             </div>
    
        <div id="ygap"></div>
    
    <?php get_footer(); ?>

    and my browser says ..

    Parse error: syntax error, unexpected $end in C:\xampp\htdocs\wordpress\wp-content\themes\techvixion\index.php on line 26

    what could be wrong? pardon me, i am a novice at php, and i started developing a theme from scratch.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You have an unclosed if condition.

    Your loop start like this :

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

    IF, there is some posts, so WHILE

    So, you need to end the while like you see in your code :

    <?php endwhile; ?>

    Then, after, you should also end the if

    <?php endif; ?>

    So, your code should look like this :

    <?php get_header(); ?>
    
    <!-- begin container -->
    
        <div id="ygap"></div>
    
        <!-- begin sidebar -->
    
        <div id="sidebar"></div>
    
        <!-- end sidebar -->
    
        <!-- begin content -->
    
        <!-- main content -->
    
             <div id="content">
             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
             <?php endwhile; ?>
    
             </div>
    
            <?php endif; ?>
    
        <div id="ygap"></div>
    
    <?php get_footer(); ?>

    S.

    put this line:

    <?php endif; ?>

    just before this line:

    <div id="ygap"></div>

    Don’t forget to use the WordPress Default Theme for examples of things such as loops. See wp-content/themes/default/index.php for an example of a loop.

    Oops, SimonJ has got it…

    Thread Starter techmulla

    (@techmulla)

    thanks guyz, resolved ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problems initiating loop’ is closed to new replies.