Php wordpress get_the_post_缩略图()不';我什么也没表现出来

Php wordpress get_the_post_缩略图()不';我什么也没表现出来,php,wordpress,wordpress-theming,Php,Wordpress,Wordpress Theming,我正在创建我的第一个wordpress主题,我不明白为什么帖子的缩略图没有显示出来。它什么也不做(没有错误)。这是我的密码: <?php $args = array( 'posts_per_page' => 3, 'category' => 6); $postslist = get_posts( $args ); foreach ( $postslist as $post ) : setup_postdata( $post ); ?&

我正在创建我的第一个wordpress主题,我不明白为什么帖子的缩略图没有显示出来。它什么也不做(没有错误)。这是我的密码:

<?php
    $args = array( 'posts_per_page' => 3, 'category' => 6);
    $postslist = get_posts( $args );
    foreach ( $postslist as $post ) :
      setup_postdata( $post );
    ?>
      <div class="col-xs-12 col-sm-4">
        <h4><?php the_title(); ?></h4>
        <?php get_the_post_thumbnail('small'); ?>
        <p><?php the_excerpt(); ?></p>
      </div>      

    <?php
    endforeach; 
    wp_reset_postdata();
  ?>

我认为这是一个小的打字错误:
samll->small

您需要像这样回显它
回显获取“post”缩略图(“small”)
get\uu
函数存储数据,但实际上不会返回数据,这就是您必须回显的原因。它们在很多情况下都很有用,比如可以将其存储在变量中,比如
$thumb small=get_the_post_thumb('small')并在整个页面中重复使用。

也可以通过这种方式使用“发布”缩略图功能获取发布图像

<?php 
 if ( has_post_thumbnail() ) {
       the_post_thumbnail('small');
 }

?>


<?php 
 if ( has_post_thumbnail() ) {
       the_post_thumbnail('small');
 }

?>