I have a stupid problem. In the custom header template I include on all pages are some images. When I set the links to the images as images/image.png it works on the homepage but not on other pages. When I set the links to these images as ../ images/image.png it works on all other pages but not on the homepage..

This is because the homepage url is given as 'mysite.com' instead of 'mysite.com/home/'.

Is there any easy solution to this problem?

My guess was to redirect any visit to the homepage to 'mysite.com/home/'. But it looks like Wordpress itself prevents this. If I type 'mysite.com/home/' in an adress bar it redirects immediately to 'mysite.com'.

I had no idea that changing these image links would give me such a weird problem :) I hope anyone here has a solution for it. Thx in advance!


1 Answer 1


Don't use relative paths in WordPress, put the images in your theme directory and use the API to output correct paths.

<img src="<?php echo get_template_directory_uri(); ?>/images/image.jpg">
  • +1, but that needs to be get_template_directory_uri(), not get_stylesheet_directory_uri(). Oct 20, 2013 at 15:30
  • 1
    @ChipBennett depends on the context, get_stylesheet_directory_uri will work for child themes. a common issue here is people using get_template_directory_uri and wondering why it's not loading assets from their child theme.
    – Milo
    Oct 20, 2013 at 15:36
  • A Child Theme is the only context in which get_stylesheet_directory_uri() should be used. I see quite a bit more confusion in Child Themes when the parent (template) mis-referenced the stylesheet directory, instead of the template directory. Oct 20, 2013 at 15:58
  • Actually, I am using child themes :) So thank you all for providing both of these functions!
    – Forza
    Oct 20, 2013 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.