【发布时间】:2017-06-13 03:49:47
【问题描述】:
如何在 Wordpress 上添加指向缩略图的链接
$output .= get_the_post_thumbnail(get_the_ID(),'Dave-profile', array('class' => 'img-responsive'));
我尝试添加
<a href="'.get_the_permalink().'"></a>
但它不起作用
【问题讨论】:
如何在 Wordpress 上添加指向缩略图的链接
$output .= get_the_post_thumbnail(get_the_ID(),'Dave-profile', array('class' => 'img-responsive'));
我尝试添加
<a href="'.get_the_permalink().'"></a>
但它不起作用
【问题讨论】:
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<?php echo $image[0]; ?>
使用上面的代码。 如果您需要更改大小,请替换“single-post-thumbnail”
缩略图、中、大、完整
【讨论】:
您可以通过多种方式实现这一点,其中一种方式是:
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>';
}
希望这会有所帮助!
【讨论】: