_e( string $text, string $domain = 'default' )
- Since
- 1.2.0
- Source
wp-includes/l10n.php:351
Echo a translated string with _e(): translates $text for the given text domain and prints it immediately, falling back to the original text. One of the oldest i18n functions in WordPress (since 1.2.0); it returns nothing, unlike __() which returns the translation.
Compatibility
- WordPress
- since 1.2.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$textstring- Text to translate.
$domainstringoptional- Text domain. Unique identifier for retrieving translated strings.
Default 'default'.Default:'default'
Code examples
Every example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Print a translatable label in a template
Use _e() for short static strings that go straight into the page, typically inside theme template files.
echo '<h2 class="section-title">';
_e( 'Latest projects', 'mytheme' );
echo '</h2>';_e() prints the translation unescaped, and translation files are external input. Prefer esc_html_e() (or esc_attr_e() in attributes) when the string lands in HTML you render.
Performance profile
How much work a call to _e() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 8
- Plugin surface
- None
- Called by
- 50
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5. The body compiles to 8.
Nothing here hands control to plugin code.
50 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()one call below _e()
Further down the call graph this can also reach query, option, cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost _e() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 8 | translate() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 8 instructions, 8 executed per call, 0 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- translate()Retrieves the translation of $text.
Used by · 50
- Custom_Background::admin_page()Displays the custom background page.
- Custom_Image_Header::show_header_selector()Displays UI for selecting one of several default headers.
- Custom_Image_Header::step_1()Displays first step of custom header image page.
- Custom_Image_Header::step_2()Displays second step of custom header image page.
- TwentyTwenty_Walker_Comment::html5_comment()Outputs a comment in the HTML5 format.
- Twenty_Eleven_Ephemera_Widget::form()Set up the widget form.
- Twenty_Fourteen_Ephemera_Widget::form()Display the form for this widget on the Widgets page of the Admin area.
- WP_Admin_Bar::_render()
- WP_Application_Passwords_List_Table::display_tablenav()Generates custom table navigation to prevent conflicting nonces.
- WP_Comments_List_Table::column_cb()
- WP_Comments_List_Table::no_items()
- WP_Customize_Background_Position_Control::content_template()Render a JS template for the content of the position control.
Show all 50
- WP_Customize_Control::render_content()Render the control's content.
- WP_Customize_Header_Image_Control::print_header_image_template()
- WP_Customize_Header_Image_Control::render_content()
- WP_Customize_Manager::render_control_templates()Renders JS templates for all registered control types.
- WP_Customize_Nav_Menu_Auto_Add_Control::content_template()Render the Underscore template for this control.
- WP_Customize_Nav_Menu_Control::content_template()JS/Underscore template for the control UI.
- WP_Customize_Nav_Menu_Item_Control::content_template()JS/Underscore template for the control UI.
- WP_Customize_Nav_Menu_Location_Control::render_content()Render content just like a normal select control.
- WP_Customize_Nav_Menus::available_items_template()Prints the HTML template used to render the add-menu-item frame.
- WP_Customize_Nav_Menus::print_custom_links_available_menu_item()Prints the markup for available menu item custom links.
- WP_Customize_Nav_Menus::print_post_type_container()Prints the markup for new menu items.
- WP_Customize_Nav_Menus::print_templates()Prints the JavaScript templates used to render Menu Customizer components.
- WP_Customize_Nav_Menus_Panel::content_template()An Underscore (JS) template for this panel's content (but not its container).
- WP_Customize_New_Menu_Control::render_content()Render the control's content.
- WP_Customize_Panel::content_template()An Underscore (JS) template for this panel's content (but not its container).
- WP_Customize_Section::render_template()An Underscore (JS) template for rendering this section.
- WP_Customize_Theme_Control::content_template()Render a JS template for theme display.
- WP_Customize_Themes_Panel::content_template()An Underscore (JS) template for this panel's content (but not its container).
- WP_Customize_Themes_Section::filter_bar_content_template()Renders the filter bar portion of a themes section as a JS template.
- WP_Customize_Themes_Section::render_template()Renders a themes section as a JS template.
- WP_Customize_Widgets::output_widget_control_templates()Renders the widget form control templates into the DOM.
- WP_Links_List_Table::column_visible()Handles the link visibility column output.
- WP_Links_List_Table::no_items()
- WP_List_Table::months_dropdown()Displays a dropdown for filtering items in the list table by month.
- WP_List_Table::no_items()Message to be displayed when there are no items
- WP_MS_Sites_List_Table::column_lastupdated()Handles the lastupdated column output.
- WP_MS_Sites_List_Table::no_items()
- WP_MS_Themes_List_Table::no_items()
- WP_MS_Users_List_Table::no_items()
- WP_Media_List_Table::column_parent()Handles the parent column output.
- WP_Media_List_Table::column_title()Handles the title column output.
- WP_Media_List_Table::no_items()
- WP_Media_List_Table::views()Overrides parent views to use the filter bar display.
- WP_Nav_Menu_Widget::form()Outputs the settings form for the Navigation Menu widget.
- WP_Plugin_Install_List_Table::display_rows()Generates the list table rows.
- WP_Plugin_Install_List_Table::no_items()
- WP_Plugins_List_Table::no_items()
- WP_Posts_List_Table::formats_dropdown()Displays a formats drop-down for filtering items.
Source code
function _e( $text, $domain = 'default' ) { echo translate( $text, $domain );}Changelog
Introduced in 1.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/l10n.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.