简体   繁体   English

循环WordPress博客文章

[英]Looping WordPress blog posts

I am struggling to loop the blog posts in my WordPress site the way I want them. 我正在努力以自己希望的方式在WordPress网站中循环发布博客文章。

I want the posts to look like this 我希望帖子看起来像这样

屏幕截图1

but due to the way I must be looping they are coming out like so 但是由于我必须循环播放的方式,它们像这样出来

屏幕截图2

This is the code I am using - I have started with a blank theme and build up from there 这是我正在使用的代码-我从一个空白主题开始,然后从那里开始

  <section class="blog-posts col-2-3 grid-pad">

    <?php while (have_posts()) : the_post(); ?>

      <article class="module">

      <li class="postWrapper" id="post-<?php the_ID(); ?>">

        <h2 class="postTitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
        <small><?php the_date(); ?> by <?php the_author(); ?></small>

        <div class="post"><?php the_content(__('(more...)')); ?></div>
      </li>



      <?php endwhile; ?>

    </article>

  </section>

<?php else: ?>

 <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>

<?php

endif;
?>

<?php if (will_paginate()): ?>

<ul id="pagination">
  <li class="previous"><?php posts_nav_link('','','&laquo; Previous Entries') ?></li>
  <li class="future"><?php posts_nav_link('','Next Entries &raquo;','') ?></li>
</ul>

<?php endif; ?>
</div> <!--END div.grid -->
</div> <!--END div.page-wrap -->
<?php
get_footer();
?>

I am fairly knew to WP so am struggling to understand how the looping works, in theory each blog post should be a module So every knew blog post is a new module. 我对WP非常了解,因此努力了解循环的工作原理,从理论上讲,每个博客帖子都应该是一个module因此,每个知道的博客帖子都是一个新模块。 In my case what is happening is each blog post is adding on to the bottom of the last creating on long module. 就我而言,正在发生的事情是每个博客帖子都添加到最后一个长模块上的底部。

It's hard to determine if this will resolve your issue w/o knowing your full HTML/CSS, but I do see you're missing a closing </article> before your <?php endwhile; ?> 很难确定这是否可以解决不知道完整HTML / CSS的问题,但是我确实看到您在<?php endwhile; ?>之前错过了</article> <?php endwhile; ?> <?php endwhile; ?>

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

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