Title: Problems initiating loop
Last modified: August 19, 2016

---

# Problems initiating loop

 *  Resolved [techmulla](https://wordpress.org/support/users/techmulla/)
 * (@techmulla)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problems-initiating-loop/)
 * i am using a different index.php as compared to my home. this is my [home.php](http://wordpress.org/support/topic/225157?replies=3).
 * 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)

 *  [SimonJ](https://wordpress.org/support/users/simonj/)
 * (@simonj)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problems-initiating-loop/#post-940020)
 * 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.
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problems-initiating-loop/#post-940021)
 * 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](http://codex.wordpress.org/The_Loop). See wp-content/themes/default/index.
   php for an example of a loop.
 * Oops, SimonJ has got it…
 *  Thread Starter [techmulla](https://wordpress.org/support/users/techmulla/)
 * (@techmulla)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/problems-initiating-loop/#post-940111)
 * thanks guyz, resolved 🙂

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems initiating loop’ is closed to new replies.

## Tags

 * [custom-template](https://wordpress.org/support/topic-tag/custom-template/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 3 replies
 * 3 participants
 * Last reply from: [techmulla](https://wordpress.org/support/users/techmulla/)
 * Last activity: [17 years, 5 months ago](https://wordpress.org/support/topic/problems-initiating-loop/#post-940111)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
