Title: Loop not working correctly
Last modified: August 21, 2016

---

# Loop not working correctly

 *  [redbird5](https://wordpress.org/support/users/redbird5/)
 * (@redbird5)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/)
 * I have been making a WordPress from scratch, this the first time for making one.
   Unfortunately I’ve been stuck for a week on trying to get the Main Index Template
   to work with the loop. This is the loop
 *     ```
       <?php get_header(); ?>
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
   
       <?php endwhile; else: ?>
       	<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
       <?php endif; ?>
   
       <?php get_footer(); ?>
       ```
   
 * This is the home page. What is going on here and why isn’t it working. I would
   like to understand how this works. I can read PHP and have a fair understanding
   of it, but I just don’t know what’s going.
 *     ```
       <div id="content">
       <div id="slideshow" class="grid_8">Slideshow?</div><!--end slideshow--> <!--Note to self put slideshow index page-->
   
       <div class="news">
       <h1 class="news">Upcoming Events</h1>
       <!--<h1 class="news">Upcoming Events</h1>-->
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacinia leo non ipsum dapibus, mattis viverra est blandit. Aenean quis mi eu lorem sollicitudin aliquet ut sed leo. Aliquam quis nibh molestie, scelerisque magna at, auctor nunc. Aliquam rhoncus interdum fermentum. Praesent blandit, lacus et ornare tristique, purus dui pellentesque lacus, non aliquam leo nisi et quam. Praesent cursus elit sed libero dignissim posuere. In sed arcu ac libero consequat convallis ut suscipit felis. Ut sollicitudin purus auctor, dignissim magna ut, ultrices augue. Nam scelerisque porta tempor. Nullam nulla justo, posuere id nisl at, elementum eleifend sem. Phasellus pretium consectetur sem, in dapibus elit viverra vel.</p>
        <div class="btn">Contact Button</div>
       </div><!--end news-->
       <div class="news">
       <h1 class="news">Featured Animal</h1>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacinia leo non ipsum dapibus, mattis viverra est blandit. Aenean quis mi eu lorem sollicitudin aliquet ut sed leo. Aliquam quis nibh molestie, scelerisque magna at, auctor nunc. Aliquam rhoncus interdum fermentum. Praesent blandit, lacus et ornare tristique, purus dui pellentesque lacus, non aliquam leo nisi et quam. Praesent cursus elit sed libero dignissim posuere. In sed arcu ac libero consequat convallis ut suscipit felis. Ut sollicitudin purus auctor, dignissim magna ut, ultrices augue. Nam scelerisque porta tempor. Nullam nulla justo, posuere id nisl at, elementum eleifend sem. Phasellus pretium consectetur sem, in dapibus elit viverra vel.</p>
        <div class="btn">Contact Button</div>
       </div><!--end news-->
       </div>
       ```
   

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

 *  [Seylin](https://wordpress.org/support/users/seylin/)
 * (@seylin)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894226)
 * Does your server have a log file? Do you see any errors in there? You may want
   to google WP DEBUG and turn that on in your wp-config.php file.
 *  Thread Starter [redbird5](https://wordpress.org/support/users/redbird5/)
 * (@redbird5)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894227)
 * I don’t see errors. I need an extra set of eyes whose more experienced in WP 
   than I am to see if there are any errors.
 * _[[No bumping](http://codex.wordpress.org/Forum_Welcome#No_Bumping). If it’s 
   that urgent, consider [hiring someone](http://directory.codepoet.com/).]_
 *  [ronangelo](https://wordpress.org/support/users/ronangelo/)
 * (@ronangelo)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894316)
 * What do you mean not working correctly? What are you expecting to happen?
    Do
   you mean no posts are appearing?
 * Some things are missing. There’s nothing in between this two codes
 *     ```
       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       ```
   
 * and this
 *     ```
       <?php endwhile; else: ?>
       ```
   
 * There should be something to indicate how the posts would appear
    You can see
   my example here [http://ronangelo.com/create-a-wordpress-theme-beginners-guide/](http://ronangelo.com/create-a-wordpress-theme-beginners-guide/)
 *  Thread Starter [redbird5](https://wordpress.org/support/users/redbird5/)
 * (@redbird5)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894323)
 * This is meant to be a home page. So the only thing that should show up is the
   contents for that page. Have I not put in the right code just yet to make everything
   work?
 *  Thread Starter [redbird5](https://wordpress.org/support/users/redbird5/)
 * (@redbird5)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894324)
 * What I’m looking to see happen is that the content shows up.
    [ This the the tutorial I’m using to create my theme.](http://blog.teamtreehouse.com/responsive-wordpress-bootstrap-theme-tutorial)
 *  Thread Starter [redbird5](https://wordpress.org/support/users/redbird5/)
 * (@redbird5)
 * [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894326)
 * I got it working. Some of the divs are sitting on top of each other, but it’s
   doing what it should be doing.

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

The topic ‘Loop not working correctly’ is closed to new replies.

 * 6 replies
 * 3 participants
 * Last reply from: [redbird5](https://wordpress.org/support/users/redbird5/)
 * Last activity: [12 years, 11 months ago](https://wordpress.org/support/topic/loop-not-working-correctly/#post-3894326)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
