您可以使用查询的对象。在博客页面上,查询的对象将保留设置为博客页面的页面的页面对象。
以下内容可以使用(如果您只需要在博客页面上显示此内容,就可以使用此功能)
/**
 * Use $post as local variable in order use setup_postdata 
 * in order to make the use of template tags available
 */
if ( is_post_page() ) { // Only target the blog page
    $post = get_queried_object();
    setup_postdata( $post ); 
        // Display the post thumbnail
        the_title();
        // Display the post thumbnail
        if ( has_post_thumbnail() ) {
            // featured image URL
            $size = \'my_custom_size\';
            $thumbnail_id =  get_post_meta( get_the_ID(), \'_thumbnail_id\', true );
            $image_src = wp_get_attachment_image_src( $thumbnail_id, $size );
            //var_dump( $image_src ); // For debugging purposes
            $url = $image_scr[0]; 
            Display post thumbnail
            the_post_thumbnail( $size );
        }
    wp_reset_postdata(); // Restore the $post global
}