<? php echo get _ _ post _ thumbnail($ post _ id); ? >
以上是我在页面上使用的代码,但页面上没有显示任何内容,想要显示最近帖子的缩略图以及博客页面上的内容
你在使用WP_Query方法吗?如果没有那么使用
$args = array( 'post_type' => 'post', 'posts_per_page'=> your_desired_number_of_post, ); // The Query $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { echo '<ul>'; while ( $the_query->have_posts() ) { echo '<li>'; $the_query->the_post(); the_post_thumbnail(); the_content(); echo '</li>'; } echo '</ul>'; } else { echo 'no posts found'; } /* Restore original Post Data */ wp_reset_postdata();
1 回答
你在使用WP_Query方法吗?如果没有那么使用