There is a code where in the background-image you need to inject php code

<div class="1" id="1" data-content-cover-id="1" data-content-cover-bg="1.jpg" data-content-cover-height="100vh" data-content-cover-parallax="fixed" style="background-image:url('1.jpg');height:100vh; "></div> 

I want to embed code in data-content-cover-bg = "1.jpg and in style =" background-image: url ('1.jpg')

 <?php echo get_the_post_thumbnail($post->ID, 'big-thumb'); ?> 

When I insert this error comes out

 " data-content-cover-height="100vh" data-content-cover-parallax="fixed" style="background-image:url('тут картинка видна');height:100vh; "> 

But not full page

mistake hike somewhere here

 data-content-cover-bg="<?php echo get_the_post_thumbnail($post->ID, 'large'); ?>" 
  • 2
    Когда вставляю вылезает такая ошибка - what error? What do you have in the error log on the server? - Visman
  • not an error more precisely, but output like this, instead of displaying the picture in full screen - reddyk
  • one
    The get_the_post_thumbnail() function displays the html-code of the image, not its address. That is, it will output not the путь_к_изображению.jpg , but <img src="путь_к_изображению.jpg"> - alenkins

1 answer 1

That's how you can do it :)

 <?php $image = wp_get_attachment_url( get_post_thumbnail_id( $post->ID )); ?> <div class="1" id="1" data-content-cover-id="1" data-content-cover-bg="<?php echo $image; ?>" data-content-cover-height="100vh" data-content-cover-parallax="fixed" style="background-image:url(<?php echo $image; ?>);height:100vh; "></div>