如果您在循环之外使用它,请尝试以下方法:
<?php
if (has_post_thumbnail( get_the_ID() )) {
    get_the_post_thumbnail( get_the_ID(), array(80,80) );
} else {
    ?>
    <img src="http://example.org/<?php the_title( get_the_ID() ); ?>" width="80px" height="80px" alt="<?php the_title( get_the_ID() ); ?>">
    <?php
} ?>
 如果您不在WP\\u查询循环中,那么发布特定的函数,如
has_post_thumbnail() the_title() 除非您显式地将帖子/页面的唯一id传递给他们,否则无法工作。