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
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.
Change Widget with Visible 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
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 ); }
Custom Title Visible
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.
DownloadSubscribe 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"]
Your plug-in worked perfectly! Thanks for that. One more issue though is that when I hover over the sidebar widget with mouse pointer, it still pops up with the title. Any idea how to get rid of that? Thanks again!
Uh, that is impossible using the plugin. It complete removes the code (not hiding the code) so there is nothing there where the title used to be.
It must be some other part of the code of the widget then. Here’s an example of what it is doing. Hover your mouse over the banners in the sidebar: http://freedomrealtyoftexas.com/buying/finding-perfect-home/
and here is a screenshot of the widget area. http://screencast.com/t/hIb6Mc7ZW
I am using the ET advertisement widget
Naw, that’s not the Widget Title, that is coming from the image’s title :
img src=”http://freedomrealtyoftexas.com/wp-content/uploads/2016/11/email-listings-banner-image.jpg” alt=”advertisement” title=”advertisement”
Notice: alt=”advertisement” and title=”advertisement”
Apparently the built in Divi advertisement widget does that on its own. You should test and see if the title and alt attributes get changed if you change the widget title and don’t hide it. Just curious.
The only way to get rid of that AFAIK is a little jQuery:
http://stackoverflow.com/questions/15364063/is-it-possible-to-hide-the-title-from-a-link-with-css
That is some serious crap. if the title and alt fields are left blank, it should pull the info from media library (in my humble opinion!). Can screw with your image SEO otherwise. I added the ‘title’ and ‘alt’ fields and now it displays and attributes the correct alt tag –> http://screencast.com/t/Ew5hnBGq
Thanks for your help!!
LOL. Mike, you need to send a missive to Elegant Themes! Actually, the Advertisement widget is not very robust. Shockingly I’m actually using it on a site here:
https://searchdronepilots.com
I don’t think it would take much to code up a plugin for that, thus being able to integrate customizations. But, why do that when there already is a plugin for that, and a plugin that is very robust 🙂
http://bit.ly/2gVk1sF
Very kool, I’ll check into that plug-in