[英]Wordpress Thumbnail link
how can I add a link to a thumbnail on Wordpress 如何在Wordpress上添加指向缩略图的链接
$output .= get_the_post_thumbnail(get_the_ID(),'Dave-profile', array('class' => 'img-responsive'));
I tried to add 我试图添加
<a href="'.get_the_permalink().'"></a>
But it doesn't work 但这不起作用
You can achieve this by many ways, one of the way is: 您可以通过多种方式实现这一目标,其中一种方式是:
if (has_post_thumbnail(get_the_ID()))
{
$output .= '<a href="' . get_permalink(get_the_ID()) . '">';
$output .= get_the_post_thumbnail(get_the_ID(), 'Dave-profile', array('class' => 'img-responsive'));
$output .= '</a>';
}
Hope this helps! 希望这可以帮助!
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<?php echo $image[0]; ?>
Use the above code. 使用上面的代码。 If you need to change the size replace "single-post-thumbnail"
如果您需要更改大小,请替换“单后缩略图”
thumbnail, medium, large, full 缩略图,中,大,完整
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.