Answer the question
In order to leave comments, you need to log in
How to display the post thumbnail in the background image of the block?
I try like this
<div class="contacts__image" style="background-image: url(<?php echo get_the_post_thumbnail_url( 'img/bg.jpg') ?>);"></div>
Answer the question
In order to leave comments, you need to log in
<div class="contacts__image" style="background-image: url(<?php echo get_the_post_thumbnail_url(get_the_ID, 'full') ?>);"></div>
You are outputting a whole img tag in styles. To get the image url, you need to use: get_the_post_thumbnail_url()
More details here: https://wp-kama.ru/function/get_the_post_thumbnail_url
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question