Both __()
and _x()
are both WordPress translation functions. The function _x() does the same thing as the function __() except the _x()
function accepts an additional parameter ($context
).
The $context
parameter allows you to have the same string translated in different ways. For example the string “tear” could be two different words:
- a tear of sadness ran down my check
- they tear off part of the ticket when I go to the ballgame
Using __()
you can have only one translation for the string “tear” but by using _x()
you can have different translations based on context.
echo _x( 'tear', 'noun: comes out of your eye when crying', 'fe_recipe' );
echo _x( 'tear', 'verb: to pull apart by force', 'fe_recipe' );
Leave a Reply