I am coding a simple plugin and I have a line of code:
echo "<p style="color:red;">Please enter a valid email address!</p>";
But in order to localize / internationalize the plugin, I need to use the function like:
_e('Please enter a valid email address!','mytextdomain')
Then may I know how do I style the text inside the _e() function?
Any help will be appreciated, thank you very much!
Regards
KC
2
Answers
You can use
sprintf
. check the below code.The Better way.
OR you can do by this way
OR
USEFUL LINKS
As per the WordPress standard you can not use the html tag inside the _e() function.
Here I have shared the WordPress official link for your reference:
URL: https://developer.wordpress.org/reference/functions/_e/
As you can see in this function 1st parameter is string $text and 2nd paramenter string $domain = ‘default’.
Here I have shared the example of code which you can use.