我想创建自定义帖子查询,在这里我将列出列表中的所有帖子。然后,棘手的一点是向列表中的第六个元素添加不同的内容。
就像这样
<li>custom post 1</li>
<li>custom post 2</li>
<li>custom post 3</li>
<li>custom post 4</li>
<li>custom post 5</li>
<li><the_content></li>
<li>custom post 6</li>
<li>custom post 7</li>
ok here is what it did:
<ul>
<?php $my_query = new WP_Query( array(
\'post_type\' => \'people\',
\'posts_per_page\' => 10,
\'order\' => \'DESC\',
\'paged\'=> $paged
) );?>
<?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
<?php if ( $my_query->current_post == 5 ) { ?>
<li>I\'m odd one</li>
<?php } else {?>
<li><?php the_title(); ?></li>
<?php } ?>
<?php endwhile; ?>
<?php wp_reset_query();?>
</ul>
我希望这有意义,非常感谢你。