繁体   English   中英

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

[英]I want to stay in the same wheel loop of WordPress, the first post will have 6 columns and the other posts will be in 6 columns

我想停留在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; ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM