How to find the directory of your WordPress Theme in PHP

To get the directory of the current theme (or child theme) you can use get_stylesheet_directory_uri(). Here’s how to use it.

Let’s assume that your WordPress installation lives in http://demo.com, and that your theme is located in a folder named “my-super-theme”. We can assume then that the full URL that points at

http://demo.com/wp-content/themes/my-super-theme/

The URL will of course be different for every user of your theme, so you can’t hard code this. Instead, you can use this handy function:

This will give you the same URL as above. You can also link to files inside your theme’s directory, for example:

get_stylesheet_directory_uri() will point to the directory of your theme or your child theme. If you’re using a child theme and want to explicitly link to the parent theme’s directory, you can use get_template_directory_uri().

From the WordPress Codex:

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!