get wordpress themes directory path
While coding for my wordpress blog i came across a scenario where i had to use the directory path of my WP themes folder. It was basically required to use the php method ‘include()’ which requires directory path of the file to be included.
To obtain the directorypath you can do something like this :
$template_url = get_bloginfo("template_url");
$theme_name = explode("wp-content/themes/",$template_url);
$theme_file_path = get_theme_root() ."/". $theme_name;
Here the first line obtains the ‘href’ for the template or themes directory of the WP installation.
In the next line we explode the url at ”wp-content/themes/”, so the path of SELECTED /ACTIVATED theme on your blog comes in the 1st location of the array $theme_name ( $theme_name ) .
get_theme_root() methods gives us the directory path till ‘wp-content/themes’ folder [without the trailing slash]
In the 3rd line we concatenate get_theme_root() with the activated theme path to obtain a full path to our themes directory [activated themes directory to be precise]
Hope it helps!!