如何在Wordpress中动态链接到缩略图

维克多

如何使用WordPress函数代替href =“ img / 1.jpg,而是获取图像缩略图Url。

<a class="popup-link" href="img/1.jpg"></a>
PHP团队

您可以使用WordPress功能获取图片缩略图网址。

<?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?> 

用法示例示例:

<?php
$imgarray = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),'full');
$imgURL = $imgarray[0];
?>
<a class="popup-link" href="<?php echo $imgURL;?>"></a>

参考法典

https://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章