Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The front page of the blog is intended to show post excerpts and a cropped version of the post image. The first/most recent excerpt is perfect, however the older subsequent excerpts are showing up somewhat shifted to the right. I'm thinking the problem lies in my loop, but I've been looking at it for so long I think a pair of fresh eyes is needed.

index.php-

<?php echo get_header();;?>
<?php echo get_sidebar();;?>

<div id="blog">
    <div class="preview">
        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        <div class="post-image">
            <?php
                if ( has_post_thumbnail() ) {
                    the_post_thumbnail( 'custom-image' );
                }
            ?>
        </div>
        <div class="post">
            <h2><?php the_title() ;?></h2>
            <span class="post-preview">
                <?php the_excerpt('read more...'); ?>
                <?php endwhile; else: ?>

                    <p>Sorry, no posts to list</p>

                <?php endif; ?>
            </span><!-- end post-preivew -->
            <p class="post-meta"><span style="font-family: amatic;">>></span>&nbsp;Posted on <?php the_date('M-d-y'); ?>&nbsp;<span style="font-family: amatic;">>></span>&nbsp;<?php the_tags('tags: ', ', ', '<br />'); ?></p><!-- end post-meta -->
        </div><!-- end post -->
    </div><!-- end preview -->
</div><!-- end blog -->

<?php get_footer(); ?>
share|improve this question
2  
you open tags inside of your loop but close them outside of it. –  Milo May 29 '13 at 18:17
    
@Milo What do you mean? –  user1255049 May 29 '13 at 18:26
1  
a while loop repeats what's inside the loop before the endwhile. you open html tags, like <div class="post"> inside the loop, but close them outside. look at where </div><!-- end post --> is in relation to where you opened it, it's after the endwhile. –  Milo May 29 '13 at 18:37
    
@Milo Got it, thank you for the explanation. –  user1255049 May 29 '13 at 19:45
add comment

closed as too localized by Milo, s_ha_dum, Michael, toscho May 29 '13 at 19:54

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

I can't add comments yet, but do you get what Milo is saying?

Just look at this section and it is as if there are no closing or tags for the classes post and post-preview.

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
            <div class="post-image">
                <?php
                    if ( has_post_thumbnail() ) {
                        the_post_thumbnail( 'custom-image' );
                    }
                ?>
            </div>
            <div class="post">
                <h2><?php the_title() ;?></h2>
                <span class="post-preview">
                    <?php the_excerpt('read more...'); ?>
                            <?php endwhile; else: ?>
share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.