特色圖像 一般是用來作為文章的縮略圖的,有些WordPress主題必須為每篇文章設置特色圖像才能顯示縮略圖。如果你的網站後臺是多人寫作,或者允許投稿,那麼你最好給“特色圖像”加點說明文字,告訴投稿者,這是做什麼用的,如下圖:
要實現這個功能,隻需將下面的代碼添加到主題的 functions.php 即可:
1 2 3 4 5 6 7 8 |
/** * WordPress 給“特色圖像”模塊添加說明文字 * https://www.wpdaxue.com/add-featured-image-instruction.html */ add_filter( 'admin_post_thumbnail_html', 'add_featured_image_instruction'); function add_featured_image_instruction( $content ) { return $content .= '<p>特色圖像將用來作為這篇文章的縮略圖,請務必為文章選擇一個特色圖像。</p>'; } |
/**
* WordPress 給“特色圖像”模塊添加說明文字
* https://www.wpdaxue.com/add-featured-image-instruction.html
*/
add_filter( ‘admin_post_thumbnail_html’, ‘add_featured_image_instruction’);
function add_featured_image_instruction( $content ) {
return $content .= ‘<p>特色圖像將用來作為這篇文章的縮略圖,請務必為文章選擇一個特色圖像。</p>’;
}
要確保必須設置特色圖像,請參考:WordPress發佈文章前強制要求上傳特色圖像