When to use _e and __ for the translation?

The question:

What is difference between _e() and __() functions for the translation? In what cases e() and __ ()should be used?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

If you want to echo the translated string, then you will be using _e and when you just want to have the translated string, then you will be using __.

Example:

_e('this is a message', 'twentyfourteen');

is same as

echo __('this is a message', 'twentyfourteen');


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment