WordPress.org

Forums

Loop Help (2 posts)

  1. KeithMKemp
    Member
    Posted 1 year ago #

    I have a website, 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.

  2. RossMitchell
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic