在Foreach循环中显示帖子缩略图

时间:2013-07-25 作者:Ciaran Gaffey

我试图在foreach循环中显示缩略图。缩略图是我添加的新图像大小,称为“植物拇指”。我有所有需要的元素显示正确,除了缩略图。这是我的代码:

      foreach ( $posts as $post ) {   

       echo \'<a class="modalLink" href="plant-list-accordion\'.$post->ID.\'" >\';
       echo get_the_post_thumbnail($thumbnail->ID, \'plant-thumb\'); //Here is where I\'m trying to output the bespoke thumbnail
       echo \'</a>\';

            $faq .= sprintf((\'<div class="modal mfp-hide" id="plant-list-accordion\'.$post->ID.\'">%1$s<div>%2$s</div>\'),
                $post->post_title,
                wpautop($post->post_content)
                 );
            $faq .= \'</div>\'; //Close the container
            }

        return $faq; //Return the HTML.
};

1 个回复
最合适的回答,由SO网友:ManuA 整理而成

echo get_the_post_thumbnail($post->ID, \'plant-thumb\');

结束