【问题标题】:wordpress - post thumbnail is not showing upwordpress - 帖子缩略图未显示
【发布时间】:2017-08-02 19:56:30
【问题描述】:

我想显示来自指定用户的帖子缩略图列表,使用此代码:

global $user;
$numposts = get_posts( array('author' => $user->ID) );

<?php foreach ($numposts as $numpost) {
the_post_thumbnail();
} ?>

缩略图没有显示。难道我做错了什么?此代码插入到插件 php 文件中。谢谢

【问题讨论】:

    标签: wordpress loops thumbnails


    【解决方案1】:

    返工和工作:

    $numposts = get_posts( array('author' => $user->ID) );
    
    <?php
    $my_query = new WP_Query( array( 'author' => $user->ID ) );
    while ( $my_query->have_posts() ) : $my_query->the_post();
    
    {
    
    echo the_post_thumbnail();
    
    }
    
    endwhile;
    ?>
    

    虽然不知道为什么它第一次没有工作。

    【讨论】:

      猜你喜欢
      • 2016-11-21
      • 1970-01-01
      • 2011-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-02
      • 2011-09-04
      相关资源
      最近更新 更多