3

This is my first post so please bear with me.

I am working on a WordPress site and came across a problem with my images.

I have a background image in my stylesheet background-image: "images/dummybg.jpg" and that works just fine and shows up

When i go to the index file and try <img src="images/dummybg.jpg"> the image does not show up.

Both the .css and index.php are loose in my folder so their relative paths SHOULD be the same. So my question is, why would one path work and not the other?

VVV
  • 7,563
  • 3
  • 34
  • 55
Zachary Almero
  • 127
  • 1
  • 2
  • 7

2 Answers2

3

WordPress has a function to get to your image directory So from your index it would be:

<img src="<?php bloginfo('template_url'); ?>/images/dummybg.jpg">
Mark
  • 6,762
  • 1
  • 33
  • 50
1

Have you used image in css. it's automatic get image path.

but if you used in any other file in tag you have must need put whole image path in src attribute.

you need to put current theme path in bellow wordpress function you will get.

get_template_directory();

if you need more details please visit wordpress functions

I am sure it's work for you.

mithun raval
  • 180
  • 3