Answer the question
In order to leave comments, you need to log in
How to insert an image in the header of a site?
Hello, now the image in the header of the site is added in this way
<img class="aligncenter" src="https://site. ru/wp-content/uploads/image.jpg" style="margin-bottom: 1px" alt="image" loading="lazy" width="1400" height="200" />
but it seems like it's not right and it needs to be inserted through CSS? Do not tell me how to do it? I tried following the instructions through the background image, but the header is constantly crooked. PS The header is just for appearance at the very top of the site.
Answer the question
In order to leave comments, you need to log in
and it needs to be inserted via CSS
but it doesn't seem right
if ( has_post_thumbnail() ) {
$background_image = get_the_post_thumbnail_url();
} else {
$background_image = get_stylesheet_directory_uri() . '/assets/img/default.jpg';
}
echo '<section class="section first-screen" style="background: url(' . $background_image . ') center/cover no-repeat">';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question