请尝试以下代码:
<?php
$args = array(
\'post_type\' => \'post\', \'posts_per_page\' => -1, \'orderby\' => \'menu_order\', \'order\' => \'ASC\',\'cat\' => \'2\',
);
$loop = new WP_Query( $args );
?>
<?php if( $loop->have_posts() ): ?>
<?php $counter = 0; while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php if ($counter % 4 == 0 && $counter != 0): ?>
</div>
</div>
<?php endif; ?>
<?php if ($counter % 4 == 0 or $counter == 0): ?>
<div>
<div>
<?php endif; ?>
<div>
<div>
<h3><?php the_title(); ?></h3>
</div>
</div>
<?php $counter++; endwhile; ?>
</div>
</div>
<?php endif; ?>
这是我在这种情况下使用的示例代码,工作起来很有魅力。只需用自定义游戏div替换必要的div即可。