请尝试此代码(&P);让我知道结果(我还没有测试)
<?php
$post_query = new WP_Query(\'post_type=post\'); // replace the post type with your post type key
$total_posts_found = $post_query->found_posts;
if($total_posts_found < 2 && $total_posts_found > 0){
if($post_query->have_posts()) : while($post_query->have_posts()) : $post_query->the_post();
echo \'<h1>\'get_the_title().\'</h1>\';
echo get_the_content();
endwhile;
endif;
wp_reset_postdata();
} else {
if($post_query->have_posts()) : while($post_query->have_posts()) : $post_query->the_post();
echo \'<h1>\'get_the_title().\'</h1>\';
echo get_the_excerpt();
endwhile;
endif;
wp_reset_postdata();
}
?>