Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress-将自定义缩略图链接到全尺寸附件图像_Php_Wordpress_Thumbnails - Fatal编程技术网

Php Wordpress-将自定义缩略图链接到全尺寸附件图像

Php Wordpress-将自定义缩略图链接到全尺寸附件图像,php,wordpress,thumbnails,Php,Wordpress,Thumbnails,我正在编写一个自定义主题,我想将自定义大小的缩略图图像链接到图像的全尺寸(或大尺寸)版本 我使用的代码是: <?php $attachment_id = get_field('main_product_photo'); $size = "main-product-thumb"; // (thumbnail, medium, large, full or custom size) wp_get_attachment_image( $attachment_id, $size ); $ima

我正在编写一个自定义主题,我想将自定义大小的缩略图图像链接到图像的全尺寸(或大尺寸)版本

我使用的代码是:

<?php 
$attachment_id = get_field('main_product_photo');
$size = "main-product-thumb"; // (thumbnail, medium, large, full or custom size)
wp_get_attachment_image( $attachment_id, $size ); 
$image = wp_get_attachment_image_src( $attachment_id, $size );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<a href="<?php echo $image[0]; ?>"><img src="<?php echo $image[0]; ?>"></a>

然而,这只是链接到我的缩略图大小的图像。有人能快速解决这个问题吗?谢谢


<?php 
$attachment_id = get_field('main_product_photo');
$size = "main-product-thumb"; // (thumbnail, medium, large, full or custom size)
wp_get_attachment_image( $attachment_id, $size ); 
$image = wp_get_attachment_image_src( $attachment_id, $size );
$post_thumbnail_url = wp_get_attachment_url( $attachment_id  );
// url = $image[0];
// width = $image[1];
// height = $image[2];
?>
<a href="<?php echo $post_thumbnail_url; ?>"><img src="<?php echo $image[0]; ?>"></a>

Hi@Phil谢谢你的回答。不幸的是,这将我带到一个404页面,因为链接试图检索/post_缩略图_url来代替实际的文件url。有什么想法吗?啊,事实上,我已经解决了。我把那块钱丢了!