Title: get_template_directory_uri
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_template_directory_uri(): string

## In this article

 * [Return](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#return)
 * [More Information](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#more-information)
    - [Notes](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#notes)
 * [Source](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#wp--skip-link--target)

Retrieves template directory URI for the active theme.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#return)󠁿

 string URI to active theme’s template directory.

## 󠀁[More Information](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#more-information)󠁿

### 󠀁[Notes](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#notes)󠁿

 * Checks for SSL
 * Does not return a trailing slash following the directory address

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#source)󠁿

    ```php
    function get_template_directory_uri() {
    	$template         = str_replace( '%2F', '/', rawurlencode( get_template() ) );
    	$theme_root_uri   = get_theme_root_uri( $template );
    	$template_dir_uri = "$theme_root_uri/$template";

    	/**
    	 * Filters the active theme directory URI.
    	 *
    	 * @since 1.5.0
    	 *
    	 * @param string $template_dir_uri The URI of the active theme directory.
    	 * @param string $template         Directory name of the active theme.
    	 * @param string $theme_root_uri   The themes root URI.
    	 */
    	return apply_filters( 'template_directory_uri', $template_dir_uri, $template, $theme_root_uri );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/theme.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/theme.php#L361)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/theme.php#L361-L376)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#hooks)󠁿

 [apply_filters( ‘template_directory_uri’, string $template_dir_uri, string $template, string $theme_root_uri )](https://developer.wordpress.org/reference/hooks/template_directory_uri/)

Filters the active theme directory URI.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#related)󠁿

| Uses | Description | 
| [get_theme_root_uri()](https://developer.wordpress.org/reference/functions/get_theme_root_uri/)`wp-includes/theme.php` |

Retrieves URI for themes directory.

  | 
| [get_template()](https://developer.wordpress.org/reference/functions/get_template/)`wp-includes/theme.php` |

Retrieves name of the active theme.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#)

| Used by | Description | 
| [WP_URL_Pattern_Prefixer::get_default_contexts()](https://developer.wordpress.org/reference/classes/wp_url_pattern_prefixer/get_default_contexts/)`wp-includes/class-wp-url-pattern-prefixer.php` |

Returns the default contexts used by the class.

  | 
| [WP_REST_Themes_Controller::prepare_item_for_response()](https://developer.wordpress.org/reference/classes/wp_rest_themes_controller/prepare_item_for_response/)`wp-includes/rest-api/endpoints/class-wp-rest-themes-controller.php` |

Prepares a single theme output for response.

  | 
| [get_parent_theme_file_uri()](https://developer.wordpress.org/reference/functions/get_parent_theme_file_uri/)`wp-includes/link-template.php` |

Retrieves the URL of a file in the parent theme.

  | 
| [get_theme_file_uri()](https://developer.wordpress.org/reference/functions/get_theme_file_uri/)`wp-includes/link-template.php` |

Retrieves the URL of a file in the theme.

  | 
| [get_editor_stylesheets()](https://developer.wordpress.org/reference/functions/get_editor_stylesheets/)`wp-includes/theme.php` |

Retrieves any registered editor stylesheet URLs.

  | 
| [Custom_Image_Header::get_default_header_images()](https://developer.wordpress.org/reference/classes/custom_image_header/get_default_header_images/)`wp-admin/includes/class-custom-image-header.php` |

Gets the details of default header images if defined.

  | 
| [Custom_Image_Header::step_1()](https://developer.wordpress.org/reference/classes/custom_image_header/step_1/)`wp-admin/includes/class-custom-image-header.php` |

Displays first step of custom header image page.

  | 
| [Custom_Image_Header::reset_header_image()](https://developer.wordpress.org/reference/classes/custom_image_header/reset_header_image/)`wp-admin/includes/class-custom-image-header.php` |

Resets a header image to the default image for the theme.

  | 
| [Custom_Image_Header::process_default_headers()](https://developer.wordpress.org/reference/classes/custom_image_header/process_default_headers/)`wp-admin/includes/class-custom-image-header.php` |

Processes the default headers.

  | 
| [WP_Customize_Manager::register_controls()](https://developer.wordpress.org/reference/classes/wp_customize_manager/register_controls/)`wp-includes/class-wp-customize-manager.php` |

Registers some default controls.

  | 
| [_get_random_header_data()](https://developer.wordpress.org/reference/functions/_get_random_header_data/)`wp-includes/theme.php` |

Gets random header image data from registered images in theme.

  | 
| [get_custom_header()](https://developer.wordpress.org/reference/functions/get_custom_header/)`wp-includes/theme.php` |

Gets the header image data.

  | 
| [get_theme_mod()](https://developer.wordpress.org/reference/functions/get_theme_mod/)`wp-includes/theme.php` |

Retrieves theme modification value for the active theme.

  | 
| [get_bloginfo()](https://developer.wordpress.org/reference/functions/get_bloginfo/)`wp-includes/general-template.php` |

Retrieves information about the current site.

  |

[Show 9 more](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 6 content](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#comment-content-1797)
 2.    [Florian Simeth](https://profiles.wordpress.org/floriansimeth/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/get_template_directory_uri/#comment-1797)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-1797)
     Vote results for this note: 44[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-1797)
 4.  This function returns the URL to the root theme. If a child theme is used and 
     you want to return the URL to the current child theme, use [get_stylesheet_directory_uri()](https://developer.wordpress.org/reference/functions/get_stylesheet_directory_uri/)
     instead.
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%3Freplytocom%3D1797%23feedback-editor-1797)
 6.   [Skip to note 7 content](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#comment-content-1822)
 7.    [Debabrata Ghosh](https://profiles.wordpress.org/debabrata-ghosh/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/get_template_directory_uri/#comment-1822)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-1822)
     Vote results for this note: 16[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-1822)
 9.  Using [get_template_directory_uri()](https://developer.wordpress.org/reference/functions/get_template_directory_uri/)
     to link a static image with its correct path in html :
 10.     ```php
         <img src="<?php echo get_template_directory_uri(); ?>/images/logo.png" width="" height="" alt="" />
         ```
     
 11.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%3Freplytocom%3D1822%23feedback-editor-1822)
 12.  [Skip to note 8 content](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#comment-content-3929)
 13.   [Carlos Longarela](https://profiles.wordpress.org/carloslongarela/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/get_template_directory_uri/#comment-3929)
 14. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-3929)
     Vote results for this note: 10[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-3929)
 15. Since WordPress 4.7.0 you can use `get_theme_file_uri()` [https://developer.wordpress.org/reference/functions/get_theme_file_uri/](https://developer.wordpress.org/reference/functions/get_theme_file_uri/)
     and this function will give us actual child theme URL or Theme URL if no child
     Theme exists.
 16.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%3Freplytocom%3D3929%23feedback-editor-3929)
 17.  [Skip to note 9 content](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#comment-content-298)
 18.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_template_directory_uri/#comment-298)
 19. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-298)
     Vote results for this note: 6[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-298)
 20. Using [get_template_directory_uri()](https://developer.wordpress.org/reference/functions/get_template_directory_uri/)
     to enqueue a script with the correct path.
 21.     ```php
         add_action('wp_enqueue_scripts', 'wpdocs_scripts_method');
     
         /*
          * Enqueue a script with the correct path.
          */
         function wpdocs_scripts_method() {
         	wp_enqueue_script(
         		'custom_script',
         		get_template_directory_uri() . '/js/custom_script.js',
         		array('jquery')
         	);
         }
         ```
     
 22.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%3Freplytocom%3D298%23feedback-editor-298)
 23.  [Skip to note 10 content](https://developer.wordpress.org/reference/functions/get_template_directory_uri/?output_format=md#comment-content-809)
 24.   [Emil Uzelac](https://profiles.wordpress.org/emiluzelac/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/get_template_directory_uri/#comment-809)
 25. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-809)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%23comment-809)
 26.     ```php
         /**
          * Enqueue scripts and styles.
          */
         function wpdocs_theme_slug_scripts() {
         	// Custom scripts require a unique slug (Theme Name).
         	wp_enqueue_script( 'theme-slug-custom-script', get_template_directory_uri() . '/js/custom-script.js', array(), '1.0.0', true );
     
         	/*
         	 * To avoid double loading Genericons will not need a slug. Same applies
         	 * to all other non-custom styles or scripts.
         	 */
         	wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '1.0.0' );
         }
         add_action( 'wp_enqueue_scripts', 'wpdocs_theme_slug_scripts' );
         ```
     
 27.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F%3Freplytocom%3D809%23feedback-editor-809)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_template_directory_uri%2F)
before being able to contribute a note or feedback.