我的wordpress博客中有10个帖子,我想要这样的话: div class =“something1” POST1 post5 post9 /格
div class =“something2” POST2 post6 post10 / DIV div class =“something3” post3 post7 post4 post8 /格
我不知道,但我必须要它,请帮助。
答案 0 :(得分:0)
在你的循环中你需要用php增加你的div。我没有对此进行测试,但这应该可行:
<div class="yourClass">
<?php
$myCustomClass = 0;
$args = array
(
'posts_per_page' => 4,
'orderby' => 'name',
'order' => 'DEC',
'post_type' => 'post',
'post_status' => 'publish'
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php $myCustomClass++ ?>
<div class="myCustomClass-<?php echo $myCustomClass;?>">
<h2>
<a href="<?php the_permalink();?>">
<?php the_title(); ?>
</a>
</h2>
<div class="my-post-content">
<?php the_content(); ?>
</div>
</div>
<? endwhile; ?>
</div>