partridj
Member
Posted 7 years ago #
I'm creating my first theme, however the paths within the theme don't seem to be relative. For instance, if I reference an image file as 'images/header.jpg' it looks in the wordpress/images directory as opposed to wordpress/wp-content/themes/mytheme/images.
Is there a place to designate the the location of the theme so it will automatically look there for relative paths?
Copernicus
Member
Posted 7 years ago #
I am new at this as well, so take my advice with a grain of salt. But, in my tinkering with themes, I have experienced your same issue & have found that the following is a solution:
replace something like:
<img src="images/header.jpg" width="300" height="25" alt="">
with this:
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/header.jpg" width="300" height="25" alt="">
partridj
Member
Posted 7 years ago #
Thanks, that works and it looks like that is how it is done in the default template. So unless I figure something else out I will assume that is how it is supposed to work.
I just whack all my images in my wp-images folder and call them using relative URL in my style.css
(/wp-images/header.jpg)
If I have lots and lots of themey images, I use folders, too.
-wp-images
--zoolander
---image.jpg
--mytheme
---image.jp
--howaboutthat
---image.jpg
(wp-images/zoolander/image.jpg)
(wp-images/mytheme/image.jpg)
(wp-images/howaboutthat/image.jpg)
works for me.