_e( string $text, string $domain = 'default' )

Display translated text.


Parameters

$text string Required
Text to translate.
$domain string Optional
Text domain. Unique identifier for retrieving translated strings.
Default 'default'.

Default: 'default'


Top ↑

Source

File: wp-includes/l10n.php. View all references

function _e( $text, $domain = 'default' ) {
	echo translate( $text, $domain );
}


Top ↑

Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 3 content
    Contributed by McContax
    _e( string $text, string $domain = 'default' )

    In this function,the “$domain” is used to locate the multilingual file.(The file which is the translation of your theme.)
    In wp-include there is a function related to this var

    function load_theme_textdomain( $domain, $path = false ) {
    $locale = apply_filters( 'theme_locale', get_locale(), $domain );
     
    if ( ! $path )
    $path = get_template_directory();
     
    // Load the textdomain from the Theme provided location, or theme directory first
    $mofile = "{$path}/{$locale}.mo";
    if ( $loaded = load_textdomain($domain, $mofile) )
    return $loaded;
     
    // Else, load textdomain from the Language directory
    $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo";
    return load_textdomain($domain, $mofile);
    }

    You can see $domain is used in this file.Actually it’s used to locate the .mo file.So you must may sure it share the same name with your theme folder name

  2. Skip to note 5 content
    Contributed by Jacob Schwartz

    Important security note: _e() is not an escaping function. Since all output really needs to be escaped, consider using __() instead.

    For example, this is safe:
    echo esc_html( __( 'This is my translatable text' ) )

    But this might not be, because the output can get filtered and is not escaped close to where it is output:
    _e( 'This is my translatable text' )

You must log in before being able to contribute a note or feedback.