gpt4 book ai didi

image - 带有链接的 Wordpress 图片附件

转载 作者:行者123 更新时间:2023-12-04 05:58:55 35 4
gpt4 key购买 nike

试图用附件/图像替换“LINK TEXT HERE”字样。我怎样才能做到这一点?

 <?php  
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'offset' => 0,
'orderby' => 'menu_order',
'order' => 'asc',
'post_status' => null,
'post_parent' => $post->ID,
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
if(wp_attachment_is_image( $attachment->ID )) {
echo '<a href="'. get_attachment_link($attachment->ID) . '">LINK TEXT HERE</a>';
break;
}
}
}

?>

最佳答案

echo '<a href="'. get_attachment_link($attachment->ID) . '">'. wp_get_attachment_image($attachment->ID) .'</a>';

关于image - 带有链接的 Wordpress 图片附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9170232/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com