To get images loaded correctly when I use img src in HTML, I have to give the entire file path. Using CSS I would only need to use:
`background-image: url(images/morebutton.png)`
With img src I have to use this:
<img src="wp-content/themes/blankslate/images/morebutton.png">
Using this file path gives me the image on the home page, however when I click through to the article page, the image doesnt load.. I’m having the same issue with my logo, it shows on the homepage, any additional pages it doesnt show.
Can anyone tell me if the file path setup I have is incorrect?
No your file path setup is correct, you need to provide the absolute path in you img src for images to load on other pages as relative path would change to,
and instead it should be
So you should define a constant in your function.php for path to image directory, and then use it in img src.
and then you can use img tag as
That would solve your issue. You can use the constant anywhere in your theme, handy to use.
Try this:
I typically let WordPress direct traffic as much as possible to avoid any conflicts. It’s definitely easier as well to always look to the predefined functions that have been built into the core.
You can use this relative path:
The
/
before the path tells the browser to go to the root directory and search for the wp-content folder and go from there.Alternatively you can always use the absolute url path in
img src
.Like
see also here how to move up or down the initial folders of your relative paths