Linking to an image folder within a WordPress theme

During WordPress theme development you will more then likely need to display some images that are located within your theme directory.

The location of the images folder can vary greatly. It really comes down to how you like to set things up.

Generally speaking if you were to have an images folder in the root of your theme you can link to it like so from your php files:

<img src="<?php bloginfo('stylesheet_directory'); ?>/images/your-image.png">

Want to become a better web developer?

Join over 25,000 other developer & designers who get awesome links to the best news and articles each week delivered directly to their inbox.

1 Comment

  1. what is stylesheet_directory, is it a directory or variable

This post currently has one response. What do you think?

You can use basic HTML when posting code, please turn all < characters into &lt; or > into &gt;
If the code is multi-line, use <pre><code></code></pre>

Leave a Reply

Your email address will not be published. Required fields are marked *