Wordpress images path not working?

I have images working on one server, but not working on another server, I don't know what happened.

Images in the path are style.css

defined as follows on both servers. I double-checked.

.category{ background:url(../images/category-icon.png); background-size:100%;}
.tabs a:hover .category{ background:url(../images/category_dark-icon.png); background-size:100%;}

      

But on server 1 it works and the url becomes like this. He works.

http://demo.server1.com/projects/gamingcafe/wp-content/themes/gamingcafe/images/category-icon.png

      

but on server 2 it is. This does not work.

http://demo.server2.com/projects/gamingcafe/wp-content/themes/images/category-icon.png

      

My directory style is similar to this on both servers.

http://demo.server1.com/projects/gamingcafe/wp-content/themes/gamingcafe/css/

http://demo.server1.com/projects/gamingcafe/wp-content/themes/gamingcafe/images/

http://demo.server1.com/projects/gamingcafe/wp-content/themes/gamingcafe/js/

http://demo.server1.com/projects/gamingcafe/wp-content/themes/gamingcafe/less/

      

same style on server2.

+3


source to share


2 answers


This is most likely due to the location where the style.css file is located.



In server1 , is the style.css file at the root of your theme directory or is it in a subdirectory?

+1


source


Step one

Check your header.php file first, whether it is correct path or not. something like this <link href="<?php echo get_template_directory_uri(); ?>/style.css" rel="stylesheet">

.

Step two

Check both servers 1 and 2 in your theme's images folder that the image should be in your theme's images folder on both servers.

Step three



You can try this way to call the image in CSS

category{ background:url("<?php bloginfo('template_directory'); ?>/images/category-icon.png"); background-size:100%;}
.tabs a:hover .category{ background:url("<?php bloginfo('template_directory'); ?>/images/category_dark-icon.png"); background-size:100%;}

      

Step four

If the above methods don't work then use another way like

<?php bloginfo('template_url'); ?>

      

0


source







All Articles