您可以使用current_post
风险值$wp_query
对象,并在特定位置或某个间隔插入标记。一个简单的例子:
while( have_posts() ):
the_post();
the_title();
the_excerpt();
// if current_post is 1, insert the div
// note that current_post starts at 0,
// so this will be after the second post\'s content
if( 1 == $wp_query->current_post ):
echo \'<div>My div!</div>\';
endif;
endwhile;