2017-02-22 74 views

回答

0

你必須把你的頁面ID靜態到一個變量,就像下面的代碼:

<?php 
$post_id = 12;  //place here your page id 
$post_thumbnail_id = get_post_thumbnail_id($post_id); 
$image = wp_get_attachment_image_src($post_thumbnail_id); ?> 

現在,這個$圖像變量放置在標籤內:

<img src="<?php echo $image[0]; ?>" /> 

我希望,這可能對你有所幫助。

+0

謝謝。這工作 –

0

是的,你可以從但你需要得到該網頁的ID。

get_the_post_thumbnail($post_id, 'full'); 

該功能爲您提供了一個頁面的特色圖像,您應該擁有您想從中獲得特定頁面的ID。您還可以傳遞您想要的圖像大小。

欲瞭解更多信息:get_the_post_thumbnail()

希望這些信息將幫助你。

相關問題