• Howdy friends. I just developing theme wordpress. I just wanna simple ask, is there any way to hide widget title when in admin widget, the title not filled or not set. thanks before.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I know topic is a bit old, but just needed this and if it can help someone.

    Code from very popular plugin using exclamation mark “!” in widgets titles to hide them. Adapted to work without “!”.

    // Add the filter and function, returning the widget title only if not empty
    add_filter( 'widget_title', 'remove_widget_title' );
    function remove_widget_title( $widget_title ) {
    	if ( substr ( $widget_title, 0, 1 ) == 0 )
    		return;
    	else
    		return ( $widget_title );
    }

    If you find problems with third party widgets use “!”, works all the time:

    // Add the filter and function, returning the widget title only if the first character is not "!"
    add_filter( 'widget_title', 'remove_widget_title' );
    function remove_widget_title( $widget_title ) {
    	if ( substr ( $widget_title, 0, 1 ) == '!' )
    		return;
    	else
    		return ( $widget_title );
    }
    Thread Starter Rahendra Putra K™

    (@rahendz)

    hi Lee, thanks for your reply. i still waiting an answer for this thing. I’ll try it, thanks again.

    Seems as it is not working. I tested on one page and there it worked for some reason. Did not tested all widgets.

    When I look at the code now I see it is not possible to work, “substr” is completely wrong there.

    Second one works allways, but would like to skip it. There are so many steps when developing website, would like to skip some.

    Thread Starter Rahendra Putra K™

    (@rahendz)

    Ok lee, so there’s no other clean way to remove the widget title when it’s not set at the admin widget page? Hope there’ll be a clean way to do it. Thanks for inform me once again.

    @paul,
    code above is from this plugin. Nothing else exist there, simple few lines plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Hide Widget Title’ is closed to new replies.