Title: load_theme_textdomain
Published: April 25, 2014
Last modified: August 20, 2026

---

# load_theme_textdomain( string $domain, string|false $path = false ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#user-contributed-notes)

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

Loads the theme’s translated strings.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#description)󠁿

If the current locale exists as a .mo file in the theme’s root directory, it will
be included in the translated strings by the $domain.

The .mo files must be named based on the locale exactly.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#parameters)󠁿

 `$domain`stringrequired

Text domain. Unique identifier for retrieving translated strings.

`$path`string|falseoptional

Path to the directory containing the .mo file.

Default:`false`

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

 bool True when textdomain is successfully loaded, false otherwise.

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

    ```php
    function load_theme_textdomain( $domain, $path = false ) {
    	/** @var WP_Textdomain_Registry $wp_textdomain_registry */
    	/** @var array<string, WP_Translations|NOOP_Translations> $l10n */
    	global $wp_textdomain_registry, $l10n;

    	if ( ! is_string( $domain ) ) {
    		return false;
    	}

    	if ( ! $path ) {
    		$path = get_template_directory();
    	}

    	$wp_textdomain_registry->set_custom_path( $domain, $path );

    	// If just-in-time loading was triggered before, reset the entry so it can be tried again.
    	if ( isset( $l10n[ $domain ] ) && $l10n[ $domain ] instanceof NOOP_Translations ) {
    		unset( $l10n[ $domain ] );
    	}

    	return true;
    }
    ```

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

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

| Uses | Description | 
| [WP_Textdomain_Registry::set_custom_path()](https://developer.wordpress.org/reference/classes/wp_textdomain_registry/set_custom_path/)`wp-includes/class-wp-textdomain-registry.php` |

Sets the custom path to the plugin’s/theme’s languages directory.

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

Retrieves template directory path for the active theme.

  |

| Used by | Description | 
| [load_child_theme_textdomain()](https://developer.wordpress.org/reference/functions/load_child_theme_textdomain/)`wp-includes/l10n.php` |

Loads the child theme’s translated strings.

  | 
| [WP_Theme::load_textdomain()](https://developer.wordpress.org/reference/classes/wp_theme/load_textdomain/)`wp-includes/class-wp-theme.php` |

Loads the theme’s textdomain.

  |

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

| Version | Description | 
| [6.7.0](https://developer.wordpress.org/reference/since/6.7.0/) | Translations are no longer immediately loaded, but handed off to the just-in-time loading mechanism. | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | The function now tries to load the .mo file from the languages directory first. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

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

 1.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#comment-content-545)
 2.    [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/load_theme_textdomain/#comment-545)
 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%2Fload_theme_textdomain%2F%23comment-545)
     Vote results for this note: 9[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%2Fload_theme_textdomain%2F%23comment-545)
 4.  **1st example**
      The `load_theme_textdomain()` function should generally be called
     from within the `after_setup_theme` action hook.
 5.      ```php
         add_action('after_setup_theme', 'wpdocs_theme_setup');
     
         /**
          * Load translations for wpdocs_theme
          */
         function wpdocs_theme_setup(){
             load_theme_textdomain('wpdocs_theme', get_template_directory() . '/languages');
         }
         ```
     
 6.  The .mo files must use language-only filenames, like `languages/de_DE.mo` in your
     theme directory.
 7.  Unlike plugin language files, a name like `my_theme-de_DE.mo` will NOT work. Although
     plugin language files allow you to specify the text-domain in the filename, this
     will NOT work with themes. Language files for themes should include the language
     shortcut ONLY.
 8.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fload_theme_textdomain%2F%3Freplytocom%3D545%23feedback-editor-545)
 9.   [Skip to note 5 content](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#comment-content-7324)
 10.   [JanLukas](https://profiles.wordpress.org/janlukas/)  [  1 year ago  ](https://developer.wordpress.org/reference/functions/load_theme_textdomain/#comment-7324)
 11. [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%2Fload_theme_textdomain%2F%23comment-7324)
     Vote results for this note: 7[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%2Fload_theme_textdomain%2F%23comment-7324)
 12. Since WordPress 6.7 this can only be called on init or later.
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fload_theme_textdomain%2F%3Freplytocom%3D7324%23feedback-editor-7324)
 14.  [Skip to note 6 content](https://developer.wordpress.org/reference/functions/load_theme_textdomain/?output_format=md#comment-content-546)
 15.   [Codex](https://profiles.wordpress.org/codex/)  [  11 years ago  ](https://developer.wordpress.org/reference/functions/load_theme_textdomain/#comment-546)
 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%2Fload_theme_textdomain%2F%23comment-546)
     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%2Fload_theme_textdomain%2F%23comment-546)
 17. **2nd example**
      you can use this example if you wish to switch theme language
     using a variable passed within the URL, for example to load the _Tamazikht_ language,
     your URL would look like; `www.example.com/?l=tz_MA`, this will search for a `.
     mo` file with name `tz_MA.mo` in the language directory inside your theme.
 18.     ```php
         // CHANGE LOCAL LANGUAGE
         // must be called before load_theme_textdomain()
     
         add_filter( 'locale', 'wpdocs_theme_localized' );
     
         /**
          * Switch to locale given as query parameter l, if present
          */
         function wpdocs_theme_localized( $locale )
         {
         	if ( isset( $_GET['l'] ) )
         	{
         		return sanitize_key( $_GET['l'] );
         	}
     
         	return $locale;
         }
     
         // SET THEME LANGUAGES DIRECTORY
         // Theme translations can be filed in the my_theme/languages/ directory
         // WordPress translations can be filed in the wp-content/languages/ directory
         load_theme_textdomain( 'wpdocs_theme_textdomain', get_template_directory().'/languages' );
         ```
     
 19.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fload_theme_textdomain%2F%3Freplytocom%3D546%23feedback-editor-546)

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