Title: Syntax error index.php help
Last modified: August 30, 2016

---

# Syntax error index.php help

 *  [danielwaddon](https://wordpress.org/support/users/danielwaddon/)
 * (@danielwaddon)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/)
 * Hi there. I am creating my first ever basic theme to get to used to coding and
   creating themes for WordPress but I have hit some syntax errors and would love
   some help / guidance. I am having problems with “<?php endwhile; ?>” and “<?php
   else : ?>”
 * Testing local error
 * Parse error: syntax error, unexpected ‘endwhile’ (T_ENDWHILE) in C:\xampp\htdocs\
   wordpress\wp-content\themes\danielwaddon\index.php on line 13
 *     ```
       <?php get_header(); ?>
       <?php if (have_posts()) ; ?>
       <?php while (have_posts()) ; the_post(); ?>
       <article <?php post_class() ?> id='post-<?php the_ID(); ?>">
       	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
           posted on: <?php echo get_the_date(); ?> at <?php echo get_the_time(); ?>
           Posted in: <?php the_category(','); ?>
   
       <?php the_content('Read More..'); ?>
       posted by: <?php the_author(); ?> | <?php comments_popup_link('No Comments','1 Comments','% Comments'); ?>
       </article>
   
       <?php endwhile; ?>
       <?php next_post_link('&laquo; Previous Entries') ?>
       <?php previous_post_link('Next Entries &raquo;') ?>
       <?php else : ?>
       <p>Not Found</p>
       <p>Sorry, but you are looking for something that isn't here.</p>
       <?php endif; ?>
       </section>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   

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

 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247193)
 * You’ve got the wrong syntax for your `if` and `while` statements. You need to
   have colons and not semicolons afterwards:
 *     ```
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       ```
   
 *  Thread Starter [danielwaddon](https://wordpress.org/support/users/danielwaddon/)
 * (@danielwaddon)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247196)
 * Thanks stephencottontail
 * I am now getting another local testing error
 * Fatal error: Call to undefined function get_header() in C:\xampp\htdocs\wordpress\
   wp-content\themes\danielwaddon\index.php on line 1
 * The new code
 *     ```
       <?php get_header(); ?>
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <article <?php post_class() ?> id='post-<?php the_ID(); ?>">
       	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
           posted on: <?php echo get_the_date(); ?> at <?php echo get_the_time(); ?>
           Posted in: <?php the_category(','); ?>
   
       <?php the_content('Read More..'); ?>
       posted by: <?php the_author(); ?> | <?php comments_popup_link('No Comments','1 Comments','% Comments'); ?>
       </article>
   
       <?php endwhile; ?>
       <?php next_post_link('&laquo; Previous Entries') ?>
       <?php previous_post_link('Next Entries &raquo;') ?>
       <?php else : ?>
       <p>Not Found</p>
       <p>Sorry, but you are looking for something that isn't here.</p>
       <?php endif; ?>
       </section>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247252)
 * How are you trying to load your theme? Are you attempting to directly access `
   index.php` (i.e., are you pointing an `<a>` tag directly at `/path/to/index.php`)?
 *  Thread Starter [danielwaddon](https://wordpress.org/support/users/danielwaddon/)
 * (@danielwaddon)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247273)
 * if I am getting your question correctly then I am calling it via the index.php
   page
 *     ```
       <?php get_header(); ?>
       <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>
       <article <?php post_class() ?> id='post-<?php the_ID(); ?>">
       	<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
           posted on: <?php echo get_the_date(); ?> at <?php echo get_the_time(); ?>
           Posted in: <?php the_category(','); ?>
   
       <?php the_content('Read More..'); ?>
       posted by: <?php the_author(); ?> | <?php comments_popup_link('No Comments','1 Comments','% Comments'); ?>
       </article>
   
       <?php endwhile; ?>
       <?php next_post_link('&laquo; Previous Entries') ?>
       <?php previous_post_link('Next Entries &raquo;') ?>
       <?php else : ?>
       <p>Not Found</p>
       <p>Sorry, but you are looking for something that isn't here.</p>
       <?php endif; ?>
       </section>
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 *  [mayraharpermr](https://wordpress.org/support/users/mayraharpermr/)
 * (@mayraharpermr)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247274)
 * Thanks your information.
 *  Thread Starter [danielwaddon](https://wordpress.org/support/users/danielwaddon/)
 * (@danielwaddon)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247275)
 * Sorry mayraharpermr. I am not sure what you are trying to say or ask for that
   matter.
 *  [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * (@stephencottontail)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247301)
 * What do you have set for “WordPress Address (URL)” and “Site Address (URL)” under
   Dashboard > Settings > General? Are you trying to access `index.php` directly,
   i.e., by going to `http://localhost/index.php`?
 * Also, can you post the contents of `header.php`?

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

The topic ‘Syntax error index.php help’ is closed to new replies.

## Tags

 * [index.php](https://wordpress.org/support/topic-tag/index-php/)
 * [syntax error](https://wordpress.org/support/topic-tag/syntax-error/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 7 replies
 * 3 participants
 * Last reply from: [stephencottontail](https://wordpress.org/support/users/stephencottontail/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/syntax-error-indexphp-help/#post-6247301)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
