Hide Divi Widget Titles

18th September 2015

Wouldn’t you have thought WordPress, by default, would have the ability to hide widget titles? Yes, we can generally change most widget titles by default, but there isn’t a built in way to make them go away on a per widget basis without digging into the core files of WordPress or a user’s supporting plugins of choice. Those options would only last until the next update cycle. There are a couple hacks to get rid of the title; one is to enter a single blank space as the title. Another is to use CSS – difficult to impossible in targeting specific widgets

WordPress Widgets Custom Title

We all appreciate easy solutions to tricky WordPress problems and it so happens that this widget title issue is easily solve with a few lines of code. If you have worked with WordPress for some time you undoubtedly have become aware of WordPress filter actions; the ‘ol “there’s a filter for that” answer to development questions. For our situation of wanting to remove a widget title on a per widget basis, we can filter out the widget’s title string one we have identified a title that should not be written.

Widget with Visible Title

Change Widget with Visible Title

Widget with Hidden Title

To Widget with No Title

CSS Method

.widget-title { display: none; }

Or

#query-posts-X .widget-title { display: none; }

DID YOU KNOW YOU CAN BANG IT?

A bang is slang used to describe the exclamation mark. The exclamation mark (!) is a punctuation mark found on the 1 key on a standard United States QWERTY keyboard. For us coders (and you can be one too) ! is the logical NOT unary operator. With a little code we can tell WordPress not to write out titles that have been BANGED. ERGO, preceding any widget’s title in an exclamation mark will result in that title not displaying on one’s blog. What is happening is by adding a few lines of code to the themes’s functions.php, we can have WordPress check to see if the title is preceded by a bang, and if it is return an empty string.

MAKE IT HAPPEN

Widgets Configuration Settings Hide Title

HOW

Cut and past code into your child theme’s functions.php file. (You ARE using a child theme aren’t you?!)

//Remove Widget Title Function
add_filter( 'widget_title', 'remove_widget_title' );
function remove_widget_title( $widget_title ) {
	if ( substr ( $widget_title, 0, 1 ) == '!' )
		return;
	else 
		return ( $widget_title );
}
Widget with Custom Title

Custom Title Visible

Widget with Custom Title Hidden

Custom Title Hidden

There’s a Plugin for That

Scared SH!TLE$$ about editing your functions.php file? Easy peasy, download Stephen Cronin‘s plugin from the repository.

Download

Get Divi Now

Get the Divi theme for WordPress - the smartest, most flexible theme in the collection. With Divi, the sky’s the limit.

Divi WordPress Theme

mailbox email subscribe

Subscribe for Divi Freebies

Plugin update notifications :: stay abreast of new and or updated items by opting in to my very occasional email newsletter. I swear by all that is right and holy your email address will never be shared, sold, traded or otherwise abused and I seriously doubt you'll see anything more than plugin/code update notifications when they are of the utmost importance.
[mailpoet_form id="1"]