WordPress.org

Support

Support » Themes and Templates » Does it really matter if its outside a div or not?

Does it really matter if its outside a div or not?

  • Does it really matter if I end my loops inside of my div for the articles or not.

    <?php endwhile; ?>
    <?php endif; ?>

    I seem to get different results if I add them outside of the closing div tag versus inside the div tag

    I mean to say, If I do this

    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
    <article class="my-articlepost">
    <p><?php the_excerpt(); ?></p>
    
    <?php endwhile; ?>
    <?php endif; ?>
    </article>

    i get something different than if I do this

    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
    <article class="my-articlepost">
    <p><?php the_excerpt(); ?></p>
      </article>
    <?php endwhile; ?>
    <?php endif; ?>

    Any thoughts?
    Just so you know, this has nothing to do with my blank page post problem. 🙂

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

    @alchymyth

    Forum Moderator

    it does matter – if you close the html tag after the loop, an dyou have more than one post, you’ll soon have to deal with http://codex.wordpress.org/Validating_a_Website

    so my “end ifs” should be after the ending </article> tag then right?

    Michael

    @alchymyth

    Forum Moderator

    if the <article> tag is after the ‘while()’ then the end </article> needs to be before the ‘endwhile’

    Ah ok so it should be like this right???

    <?php endwhile; ?>
    </article>
    <?php endif; ?>

    Is this correct?
    Are there other conditions that may require something different like having both after the article tag? Or is this pretty much cut and dried?

    Michael

    @alchymyth

    Forum Moderator

    Is this correct?

    no –

    you already posted the right code:

    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
    <article class="my-articlepost">
    <p><?php the_excerpt(); ?></p>
      </article>
    <?php endwhile; ?>
    <?php endif; ?>

    this code wraps each post correctly in an <article> tag

    Ah, ok gothcha, Thanks or the tip. I am a noob theme dev and sometimes the codex make me crazy, lol. My new theme is for a real estate site at http://www.entechpc.com and this is where I am having all of the issues, lol.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Does it really matter if its outside a div or not?’ is closed to new replies.
Skip to toolbar