I am trying to add some static images to the single product template in WooCommerce but they are not displaying properly.

I am hooking into the woocommerce_after_single_product_summary hook and everything is being included in the file fine.

I have added, among other things, the following code:

<div class="product-detail-header">
    <img src="<?php echo get_stylesheet_directory(); ?>/images/sig-technical.png" />

For some reason the image path is inserting itself after the path of the current page which is obviously not where it should be pointing to.

It is translating to


instead of


I've been racking my brain and can't figure this one out. Any ideas would be greatly appreciated.

  • Try get_stylsheet_directory_uri() instead. Jan 22, 2016 at 5:54
  • That worked! Thanks a ton! I kinda feel stupid for not having tried that lol. Jan 22, 2016 at 6:16
  • I've done the same thing a hundred times probably. You should post your code as an answer for others, it will help someone I'm sure. Jan 22, 2016 at 6:21

1 Answer 1


Many thanks to Nathan Powell for the fix.

Changing get_stylesheet_directory() to get_stylesheet_directory_uri() will return the correct URL.

get_stylesheet_directory() returns the absolute server path to child or parent theme (hence my previous issue) whereas get_stylesheet_directory_uri() returns the properly formed URI of child or parent theme.

I suppose the lesson is to pay close attention to exactly what function you're using as WordPress has many similarly named plugins.

You can check out the codex docs here: get_stylesheet_directory() & get_stylesheet_directory_uri()

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.