[英]How to make img src URL as Featured Image
我正在嘗試使用以下主題從img src
網址制作“精選圖片”: https : //themezee.com/themes/donovan/
<a href="https://i.imgur.com/UJs4AKj.jpg"><img src="https://i.imgur.com/UJs4AKj.jpg" /></a>
請使用以下代碼帖子獲取帖子精選圖片。
<?php
$imageId = get_post_thumbnail_id( $post_id);
$imageURL = wp_get_attachment_image_src( $imageId ), 'full' );
echo '<a href="'.$imageURL.'" target="_blank"><img src="'.$imageURL.'" /></a>';
我想這會解決你的問題。
<?php if (has_post_thumbnail( get_the_ID() ) ):
$image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' ); ?>
?>
<img src="<?php echo $image[0]; ?>"/>
<?php endif; ?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.