• Resolved dexteremmerich


    Sorry, I couldn’t seem to find this anywhere but I know someone must’ve asked it before. I know _e() is used for echoing things through WordPress, but I was reading a tutorial and the way the guy put it, he made it sound like it’s bad practice to not echo certain things through _e(), and instead make it just plain HTML.

    Is there truth to this? If I was going to sell templates, should certain things be _e()’d instead of just placed in there? Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thanks, especially for such a speedy response! So, basically I should just use it everywhere the I’m displaying text, right?

    If your theme supports translation, then sure it’s worth wrapping anything that is written text (ie. something written in your language) in a translatable string. Your theme needs to register an approprite text domain in order for those translatable strings to be of any use though (same applies to plugins).

    In regard to what to wrap in translation strings, take this example..

    echo '<div class="wrapper">';

    This would be totally pointless as..

    _e('<div class="wrapper">', 'theme_text_domainname');

    There’s nothing to translate, the code is layout markup, that deals with display not written words.

    However, take this example..

    echo 'Hello, i'm some text explaining or describing something';


    _e('Hello, i'm some text explaining or describing something', 'theme_text_domainname');

    The first string is written in english, and stuck in english, it’s hard-coded so to speak.

    The second string is translatable, and assuming your theme has registered a text domain (required in order for anyone to make a translation) could be translated into another language.

    For words, yes certainly make them translatable strings (why not?), but for layout markup it’s not necessary(nor correct impo), if you want to give users the ability to change markup(ie. HTML), you should supply an appropriate filter, eg. apply_filters('my_filter', $example_var_holding_markup ).

    Does that help?

    Yup, that clears it up for me. Thanks so much!

    You’re welcome…. 🙂

    Hi thanks for those informations, I have another question about the “theme_text_domainname” part…

    So when we use the following function in a .php file :
    _e('<div class="wrapper">', 'theme_text_domainname');

    Does it mean we must have a “theme_text_domainname-fr_FR.po” file located in the same directory as the .php file ?

    Thank you 🙂

    The file should be placed wherever the domain is set to read language files from..

    If the path (second parameter of load_theme_textdomain function) looked like so..

    get_template_directory() . '/languages'

    Then it would go into the theme’s languages folder.. ie. wp-content/themes/YOUR_THEME/languages


    Additional: I’ve just spotted something important on the above link, and i don’t know whether this is still true, but it appears the naming scheme differs for theme text domains (see the link), just wanted to point this out.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘_e()’ is closed to new replies.