我希望保持在WordPress的同一轮循环中,第一个帖子将有6列,其他帖子将在6列中

问题描述 投票:0回答:1

我想留在WordPress的同一轮循环,第一个帖子将有6列,其他帖子将在6列。例如http://prntscr.com/mvx453我的HTML代码https:// PasteBin。低/ uQvcsP8h

jquery wordpress html5
1个回答
0
投票
     <?php
    // checks if there are any posts that match the query
    if (have_posts()) :
        $i=1;
     ?>
    <div class="col-md-6">
<?php
    // If there are posts matching the query then start the loop
    while ( have_posts() ) : the_post();
        // the code between the while loop will be repeated for each post
        ?>

        <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>

        <p class="date-author">Posted: <?php the_date(); ?> by <?php the_author(); ?></p>

        <?php if($i==1){ ?>
            </div>
            <div class="col-md-6">
        <?php } ?>

    <?php
        $i++;
        // Stop the loop when all posts are displayed
    endwhile; ?>
    </div>
<?php
// If no posts were found
else : ?>
    <p>Sorry no posts matched your criteria.</p>
<?php endif; ?>
© www.soinside.com 2019 - 2024. All rights reserved.