0
I am creating a theme from scratch in Wordpress, and would like to make, in the header, a background with a custom image. I’m trying to do it on front-page.php myself.
First, that I tried to access the image through the path:
img/background.jpg
And it didn’t work. At first, I added the image to the library. Retrieved the entire address as if it were uploaded, so yes I was able to add the image through a specific path.
However, how do I customize the image? Because I intend to make the site responsive, and I need to access both the image, when the div that skirts it.
The code:
front-page.php
<div class="header-image">
<img src="enderecoDaImagem/background.jpg" alt="Roma" />
</div><!-- /header-image -->
<?php if (have_posts()) :
while (have_posts()) : the_post();
the_content();
endwhile;
else :
echo '<p> Não tem Posts </p>';
endif;
?>
css style.
img{
text-align: center;
max-width: 100%; /*Isso faz com que a imagem não saia de dentro do wrapper.*/
height: auto;
}
.header-image{
border: 3px solid red;
max-width: 1000px;
}
Not even putting a border in the class it is applied.
I mean, the image appears, but I can’t customize it.
What exactly do you mean by "customize the image"?
– Bruno Augusto
Leave the image with a width: 100%, for example. , or apply a border to it. Anyway, I would like to be able to access this image: div.nomenClasse img
– Wesley Redfield
So it’s a CSS problem, only. If the image is appearing, then it is being inserted into the element, either as a background of a DIV or as an IMG element. That said, how’s your CSS?
– Bruno Augusto
I updated the post.
– Wesley Redfield
I don’t understand your problem. Your code works as expected (although the correct one is
.header-image img
, not to affect the other images of the theme). So, are you sure that the CSS is being requested along with the page? Take a look at your browser’s Network Inspector and see if you don’t have a 404 pro CSS.– Bruno Augusto
Thanks Bruno! In fact, I wasn’t recovering CSS. Although I haven’t yet tested specifically what I want, I wasn’t even recovering the CSS.<br/> In class, the teacher created the page header.php so that the style sheet could be included. <br/> ;index.php ->(requires)-> header.php ->(requires) -> functions.php. <br/> Wordpress has the function wp_header();. This function requires for the page functions.php. And within the Function.php you have the requisition of the cascade sheet.
– Wesley Redfield