_e function in wordpress

_e function in WordPress is frequently used when we need to create a dynamic text. It is used to add some dynamic text in your post and add some extra information to your website. There are two types of _e function in WordPress.

e-function-in-wordpress

What is use of __() and _e() functions in WordPress?

WordPress supports multiple languages, so when you write some label or text in code. you cant simply echo it but you need to follow the standard function to do it is _e which supports a multi-language translation feature, each of these functions has a two-parameter.

  • 1st parameter: String which you want to convert from one language to another.
  • 2nd parameter: domain name.

 

What are the differences between _e () or __?

So the main difference between __ and _e is that the latter one echoes the result to the webpage. __ serves as the alias of the function. These functions can be found in wp-includes/l10n.php.

Reference pages for the functions here:

  • _e
  • _n
  • __

 

_e is used for simple text while _n can be used for the plural form of a word, you can even define different forms for different numbers of an object or thing.

<!– Making a h1 heading –>
<h1><?php _e(“apple”); ?></h1>

<!– Sample paragraph –>
<p><?php _n(“piece”, “pieces”, 3); ?></p>

WordPress project you can use the __ function, which returns the translated version of the given string. This returned string can be integrated in whatever WordPress code you want.

For Developers

// return the translation of apple in a German sentence
echo “Das ist ein ” . __(“apple”) . “!”;

Source : https://code.tutsplus.com/articles/quick-tip-using-the-mysteriously-named-_e-_n-and-__-functions–wp-26092

 

The _e function is primarily used to display the author’s content in the manner specified by the regular expression, function parameters, and theme function parameters. Any content between the tags is displayed.

Leave a Comment