Title: Loop Help
Last modified: August 22, 2016

---

# Loop Help

 *  [KeithMKemp](https://wordpress.org/support/users/keithmkemp/)
 * (@keithmkemp)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/loop-help-3/)
 * I have a website, [thethoughtbubble.me](http://www.thethoughtbubble.me)
    It’s
   currently under construction, but close to done.
 * I’m having issues with my categories links.
 * If I used the following HTML and PHP, my site breaks. The stick-it notes get 
   all screwed up.
 *     ```
       <?php get_header(); ?>
       <?php include('nav.php'); ?>
   
       <div id="mainContainer">
           	<div id="mainContentContainer" class="borderDefault">
       		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                   <div id="contentDate">
                   Posted on <?php the_time('F jS, Y') ?>
               	</div>
                   <div id="contentNavContainer">
       	    	</div>
                   <div id="contentTitle">
                   <h1><?php the_title(); ?></h1>
                   </div>
                   <div id="content">
                 	<p><?php the_content(__('(more...)')); ?></p>
       		<?php endwhile; else: ?>
       		<p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
                   </div>
               </div>
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * However, as soon as I remove any information pertaining to the loop and am left
   with:
 *     ```
       <?php get_header(); ?>
       <?php include('nav.php'); ?>
   
       <div id="mainContainer">
           	<div id="mainContentContainer" class="borderDefault">
                   <div id="contentDate">
                   </div>
                   <div id="contentNavContainer">
       	    </div>
                   <div id="contentTitle">
                   <h1></h1>
                   </div>
                   <div id="content">
                   </div>
               </div>
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * My site works fine.
    Any thoughts? I don’t think it’s my HTML, as the other parts
   of the site are working. It’s only on when you click on a category.

Viewing 1 replies (of 1 total)

 *  [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * (@rossmitchell)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/loop-help-3/#post-5176305)
 * I think your WHILE is including a surplus `<DIV id="content">` which is not closed
   within the loop. You need to emit `</div>` before the ELSE and before the ENDIF,
   and remove the `</div>` that is after the endif.
 * Also as presented your `<div id="mainContainer">` is not closed, but this is 
   likely because you have only given part of the code.

Viewing 1 replies (of 1 total)

The topic ‘Loop Help’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [RossMitchell](https://wordpress.org/support/users/rossmitchell/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/loop-help-3/#post-5176305)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
