Html Tag in Title

Suppose if we have to add title like this
<h1>Main Heading</h1><h2>Sub Heading</h2>


1- Add this code in function file:

function your_html_widget_title( $title ) { 
 $title = str_replace( '[', '<', $title );
 $title = str_replace( '[/', '</', $title );
 $title = str_replace( ']', '>', $title );
 return $title;
}

add_filter( 'widget_title', 'your_html_widget_title' );
add_filter( 'title', 'your_html_widget_title' );

 

2- Now replace less than or greater than sign with Square Brackets like this:
[h1]Main Heading[/h1][h2]Sub Heading[/h2]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s