如何查询要插入的帖子

时间:2014-03-17 23:04:54

标签: php wordpress zurb-foundation

所以我设法查询我的帖子,但是在前2列之后,它们在下面正确地断开/未正确对齐。所以我想每行插入2个帖子,抱歉,如果我的解释非常糟糕。enter image description here

$loop = new WP_Query( array( 'post_type' => 'team') ); ?>

        <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>

            <!-- <div class="large-6 columns"> -->
                <div class="row">
                    <div class="large-3 columns">
                        <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
                            <?php echo get_the_post_thumbnail($page->ID, 'medium'); ?>

                        <?php else: // use this image to fill the thumbnail ?>
                            <img src="http://placehold.it/350x150">
                        <?php endif; ?>
                    </div>

                    <div class="large-9 columns">
                        <div class="panel radius">
                            <h3><?php the_title(); ?></h3>
                                <p><?php the_content(); ?></p>
                                <?php edit_post_link(); // Always handy to have Edit Post Links available ?>
                        </div>
                    </div>
                </div>
            <!-- </div> -->
        <?php endwhile; ?>

1 个答案:

答案 0 :(得分:3)

不是zurb用户,但我希望你需要每2个帖子开一个新行:

$loop = new WP_Query( array( 'post_type' => 'team') ); 
$counter=0;
?>

    <?php while ( $loop->have_posts() ) : $loop->the_post(); $counter++;?>
            <div class="row">
                <div class="large-3 columns">
                    <?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
                        <?php echo get_the_post_thumbnail($page->ID, 'medium'); ?>

                    <?php else: // use this image to fill the thumbnail ?>
                        <img src="http://placehold.it/350x150">
                    <?php endif; ?>
                </div>

                <div class="large-9 columns">
                    <div class="panel radius">
                        <h3><?php the_title(); ?></h3>
                            <p><?php the_content(); ?></p>
                            <?php edit_post_link(); // Always handy to have Edit Post Links available ?>
                    </div>
                </div>
            </div>


            <?php 
              //close row div and start another every 2 posts
              if ($counter%2==0):?>
                </div><div class="row"> 
            <?php endif;?>


    <?php endwhile; ?>