PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, February 5, 2022

[FIXED] How to style text inside _e() wordpress function?

 February 05, 2022     css, php, plugins, wordpress     No comments   

Issue

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


Solution

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.

echo '<p style="color:red;">' . __( 'Please enter a valid email address!', 'mytextdomain' ) . '</p>';


Answered By - ZealousWeb
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing