php – What does the WordPress _e() function do?

php – What does the WordPress _e() function do?

https://developer.wordpress.org/reference/functions/_e/

In WordPress, strings in the php files are marked for translation to other languages, and localization using two “tags” which are actually functions. They are:

__()
_e()

They are used for localization in WordPress themes. If youre only using one language for your theme, you dont need them.

php – What does the WordPress _e() function do?

It is a WordPress Function used for localization.
See the WordPress Docs for localization.

With this function you can output/assign hardcoded strings within your theme/plugin/code that are translateable (with .mo / .po files or plugins like WPML String Translation).

The function __( My Text, my-text-domain ); assigns a string My Text that is translateable. my-text-domain is the text-doamin the string is referenced to. This function does not echo anything!

The function _e( My Text, my-text-domain ); is almost the same but it echoes your string directly.

WordPress Offers several other functions for localization, take a look into the Codex (link on top of my answer).

Leave a Reply

Your email address will not be published.