获取帖子缩略图以显示收藏夹

时间:2015-08-25 作者:Graham Slick

我用这句话:

echo (the_user_favorites_list($user_id = um_profile_id(), $site_id = null, $include_links = true, $filters = null, $post_thumbnail_id = get_post_thumbnail_id()));
显示用户的收藏夹,但只显示帖子的链接。我想:

$post_thumbnail_id = get_post_thumbnail_id()
也会显示缩略图,但事实并非如此。我应该如何修改此内容以使其具有:

*Post1 title link*
*Thumbnail1* 

*Post2 title link*
*Thumbnail2* 
代码如下:

function get_user_favorites_list($user_id = null, $site_id = null, $include_links = false, $filters = null, $include_button = false)
{
    global $blog_id;
    $site_id = ( is_multisite() && is_null($site_id) ) ? $blog_id : $site_id;
    if ( !is_multisite() ) $site_id = 1;
    $favorites = new UserFavorites($user_id, $site_id, $include_links, $filters);
    return $favorites->getFavoritesList($include_button);
}

function the_user_favorites_list($user_id = null, $site_id = null, $include_links = false, $filters = null, $include_button = false)
{
    echo get_user_favorites_list($user_id, $site_id, $include_links, $filters, $include_button);
}
谢谢你的帮助

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

get_post_thumbnail_id() 仅返回缩略图的ID。要获取实际缩略图,可以使用get_the_post_thumbnail()

您也可以使用图像的ID获取图像,但这需要wp_get_attachment_image( get_post_thumbnail_id(), \'full\' )

相关推荐