Image path for themes (4 posts)

  1. partridj
    Posted 9 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?

  2. Copernicus
    Posted 9 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="">

  3. partridj
    Posted 9 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.

  4. katie1
    Posted 9 years ago #

    I just whack all my images in my wp-images folder and call them using relative URL in my style.css


    If I have lots and lots of themey images, I use folders, too.



    works for me.

Topic Closed

This topic has been closed to new replies.

About this Topic