J
J
JyriG2018-07-29 12:08:42
css
JyriG, 2018-07-29 12:08:42

How to set the path in the background-image on wordpress so that the image appears?

Tried

background-image: url("<?php bloginfo('template_url'); ?>/img/Fon_kopia_4.jpg");

but didn't work. What other ways are there?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Renat Grishin, 2018-08-01
@JyriG

Alternatively, you can also set the style in the html document in the head

<html>
    <head>
        (...)
        <style>
            body {
            background-image: url(<?php bloginfo('template_url'); ?>/images/bg.jpg);
            }
        </style>
   </head>
   <body> (...) </body>
</html>

D
Dima Polos, 2018-07-29
@dimovich85

Have you tried the normal relative path?

O
Orkhan Hasanli, 2018-07-29
@azerphoenix

Hello!
<?php bloginfo('template_url'); ?> would most likely work if the images were not rendered in css. Check if the path to the image is displayed correctly.
Otherwise, you can display the image by specifying a relative path starting from wp-content/uploads
I don’t understand what the img folder is and where exactly it is located ... but as I understand it, you changed the media upload root directory from uploads to img?
PS do not need to specify an absolute path, because if in the future you connect an SSL certificate, you will need to change http --> https everywhere

A
Alexander Grimashevich, 2018-08-09
@jams

If in the .php file you need to write something like this:

<style>
    body {background-image: url(<?php echo get_template_directory_uri(); ?>/images/bg.jpg);}
</style>

If in .css, then like this:
body {
    background-image: url("../images/bg.jpg");
}

either like this:
body {
    background: url("../images/bg.jpg") no-repeat center;
    background-size: cover;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question