没有WordPress函数wp\\u get\\u attachment\\u src当您想要得到答案时,您应该清除您的问题,并进行描述性说明
我正在给你解释你的问题。您认为wp\\u get\\u attachment\\u url/wp\\u get\\u attachment\\u src/get\\u post\\u thumbnail\\u id有什么区别?
wp_get_attachment_url($id)
返回附件文件的完整URI,失败时返回false。此处id为附件帖子id
Example
echo wp_get_attachment_url( $id );
echo wp_get_attachment_url( 12 );
$example_url = wp_get_attachment_url( get_post_thumbnail_id() );
echo \'<div style="background-image:url(\'.$example_url.\');"></div>\';
wp_get_attachment_image_src()
返回图像属性的数组值
Example
wp_get_attachment_image_src( int $attachment_id, string|array $size = \'thumbnail\', bool $icon = false )
$image_attributes = wp_get_attachment_image_src( $attachment_id = 8 );
if ( $image_attributes ) : ?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
get_post_thumbnail_id()返回特色图像id
一
get_post_thumbnail_id($post_id)
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
Now Solution of your problem
我猜$photo\\u id是您的帖子id<li><a data-image-id="\'.$photo_id.\'" href="\'. get_permalink($photo_id).\'">
<img data-image-id="\'.$photo_id.\'" class="thumbnail" src="\'.get_the_post_thumbnail( $photo_id, \'thumbnail\', array( \'class\' => \'alignleft\' ) );.\'"></a>
</li>
有关更多信息,请参阅法典:get_post_thumbnail_id()
wp_get_attachment_image_src()
wp_get_attachment_url()