问题是WordPress在自定义查询之前执行主查询(主查询仅基于默认的帖子类型)。
您可以截取主查询,修改它,然后像这样使用它
function add_blog_post_to_query( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( \'post_type\', array(\'post\', \'blog_post\') );
        $query->set( \'posts_per_page\', 3 );
    }
}
add_action( \'pre_get_posts\', \'add_blog_post_to_query\' );
 如果你想继续使用你的自定义
pagination 你可以这样称呼它
if ( function_exists( \'pagination\' ) ) {
    global $wp_query;
    pagination( $wp_query->max_num_pages );
}
 现在,您可以使用以下标准函数,而不是使用自定义查询:
if ( have_posts() ) :
    /* Start the Loop */
    while ( have_posts() ) : the_post();
        // your markup here
    endwhile;
else :
    // no posts found
endif;