Enable HTML code in the title of the WordPress widget

Although there is now a special HTML widget in WordPress, it is still not possible to place HTML code in the widget title. This can be useful if you want to address parts of a title, e. g. for CSS formatting.

There are two ways to solve this problem. You can install the plugin HTML Widget Titles or add the following code to the functions.php:

// Enable HTML code in the title of the WordPress widget
function html_widget_title( $var) {
$var = (str_replace( '[', '<', $var ));
$var = (str_replace( ']', '>', $var ));
return $var ;
}
add_filter( 'widget_title', 'html_widget_title' );

Source: GitHub Gist

Both the plugin and the code in functions.php work the same way. Both solutions simply replace square brackets [] with angle brackets<>, so that the output can be done via HTML. You trick WordPress.

If you want to mark a part of the widget title with HTML, you have to enter the following:

This is [strong]my[/strong] Tutorial will then be this is my Tutorial

Even marking with classes works, but you have to omit the quotation marks:

This is [strong class=border]my[/strong] will then result in the following HTML output This is <strong class="border">my</strong> Tutorial.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Dear ...i appreciate your work..... i am a IT engineer ... i just want to start a eCommerce business ....thats why i am trying to develop a eCommerce site in wordpress ...is this a wise decision or not....???? give me a little tips...

That's very ambitious what you have in mind.

Do you know WooCommerce? This so called "State of the Art" in the Field "WordPress & eCommerce".

yes i know....

Hey @vladimir-simovic I am @utopian-io. I have just upvoted you at 4% Power!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Work on your followers to increase the votes/rewards. My vote is on the human input. Good luck!
  • Contribute more often to get higher and higher rewards. I want to see you often!
  • Wondering why other contributions got more? I introduced a competition factor. My vote is based also on how competitive the category used is.

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.079
BTC 62649.11
ETH 1652.93
USDT 1.00
SBD 0.41