WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a multisite and need a function (added to functions.php) that will get the template url of the second theme (probably by name or other identifier)?

Example: theme-1 (used by main site) contains function to get url of theme-2 (theme-2 is used by sub-sites)


share|improve this question
up vote 4 down vote accepted

You can use two inbuilt functions to do this.

  1. switch_to_blog
  2. get_stylesheet_directory_uri

You can use both in the following way to make a function out of it which would give you the url to the theme. Put the below in the functions.php file

function wpse_get_theme_url( $blog_id = 1 ){
    switch_to_blog( $blog_id );

    $template_url = get_stylesheet_directory_uri();
    restore_current_blog(); // Switch back to the original blog

    return $template_url;

Now you can use the above function to fetch the url by using the function and passing the blog id/ sub site id.

$theme_url = wpse_get_theme_url( $blog_id );
// Replace the $blog_id with blog id of your sub sites.
share|improve this answer
Thank you very much, that worked well!! – Alexnl Nov 26 '13 at 18:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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