最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

posts - Set featured image as hero image on each page

programmeradmin0浏览0评论

I want my post's featured image show as a full width hero image. I have tried to set the featured images as background images in a full-width row, but I think it is not possible.

If anyone have the answer or a way to set the featured image as a hero, then please suggest.

I want my post's featured image show as a full width hero image. I have tried to set the featured images as background images in a full-width row, but I think it is not possible.

If anyone have the answer or a way to set the featured image as a hero, then please suggest.

Share Improve this question asked Feb 21, 2020 at 13:27 Suman MSuman M 31 bronze badge 1
  • Please edit your question to specify what you've tried and what specific problems you're having. Relevant code samples will make it much easier to assist you. – Pat J Commented Feb 21, 2020 at 17:32
Add a comment  | 

1 Answer 1

Reset to default 0

You need to look at how your theme is rendering the hero image. Then, before it does so, add an if block which checks for a featured image. If a featured image exists, replace the hero image with it. Your code will look something like this.


if ( has_post_thumbnail() ) {
  // render hero image using the_post_thumbnail() instead
}
发布评论

评论列表(0)

  1. 暂无评论