WordPress at a glance

esc_html_e() WP 2.8.0

Translates specified string and replaces special characters in it with HTML entities. Displays text that can be used in HTML as HTML code.

If you need to get the same sting without printing it — just use esc_html__().

Works based on: esc_html(), translate()

No Hooks.


null. Nothing.


esc_html_e( $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 such a string with this function:

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

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

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

// Or so
echo esc_html__('Any text with <div>HTML.</div>', 'kama');


Since 2.8.0 Introduced.

Code of esc_html_e() WP 5.7.2

function esc_html_e( $text, $domain = 'default' ) {
	echo esc_html( translate( $text, $domain ) );

From tag: esc_ (clean validate sanitize)

More from tag: localize (l10n i18n Internationalization localization)

More from category: Localization

No comments
    Log In