我想留在WordPress的同一轮环中,第一篇文章将有6列,其他帖子将在6列中



我想留在WordPress的同一轮环中,第一篇文章将有6列,其他帖子将在6列中。例如http://prntscr.com/mvx453我的html代码https://pastebin。低/UQVCSP8H

     <?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; ?>

最新更新