I am developing a WordPress site based on a theme developed using Twitter Bootstrap. I have a banner image specified in my header.php which is loaded at the top of every page.

Added the image path

After having made the requisite changes in the header.php to include the path

<img src="<?php echo get_stylesheet_directory();?>/images/headerbg.jpg" alt="the image is not showing" class="img-responsive center-block"/>

My image still does not show and the alt tag is shown

enter image description here:

Confirming the image path is correct and working

When directly using the computed code from the browser, I am able to access the image:

enter image description here


Use get_stylesheet_directory_uri() instead of get_stylesheet_directory().

<img src="<?php echo get_stylesheet_directory_uri();?>/images/headerbg.jpg" ..../>

get_stylesheet_directory_uri() returns URI of the stylesheet directory where as get_stylesheet_directory() returns the path on the server to the stylesheet directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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