是的,您可以在循环中使用$wp\\u query->current\\u post来完成此操作。它返回循环内的当前posts索引号(从0开始)。查看以下代码块
<?php
global $wp_query;
while(have_posts()){
    the_post();
    the_title();
    //do your other stuff
    if($wp_query->current_post==1){
        //do what you want to do after 2nd post
    }else if($wp_query->current_post==5){
        //do what you want to do after 6th post
    }
}