WordPress at Your Fingertips

esc_html__() WP 2.8.0

Translates specified string and escapes it for safe use in HTML output.

If there is no translation, or the text domain isn't loaded, the original text is escaped and returned.

No Hooks.


String. Translated and escaped string for output in HTML.


esc_html__( $text, $domain );
$text(string) (required)
Text to translate.
Text domain. Unique identifier for retrieving translated strings.
Default: 'default'


#1 Output in the tag

If the translation has HTML tags or characters that need to be shown as it is, for example in <textarea> tag, then it is smart to translate it with this function:

	<?php echo esc_html__('Any text with <span>HTML.</span>', 'textdomain'); ?>

#1.2 Same as in the first example but in a different way

<?php echo esc_html( __('Any text with <span>HTML.</span>', 'textdomain') );


Since 2.8.0 Introduced.

Code of esc_html__() WP 5.8

function esc_html__( $text, $domain = 'default' ) {
	return esc_html( translate( $text, $domain ) );

From tag: localize (l10n i18n Internationalization localization)

More from category: Localization

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In