25

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

2

1 Answer 1

47

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');
2
  • Does _e() return the translated string, or just echo in place? For example, would $x = _e('1','2'); echo $x echo the translated string twice? Would the first line run?
    – user38365
    Mar 25, 2020 at 21:42
  • __('this is a message', 'twentyfourteen'); gives the translated string. Then it's upto you how you want to use that result. Apr 11, 2020 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.