WordPress dynamic sidebar without title

I’d like to pull in a dynamic sidebar. I have 1 text item in the widget sidebar but I DON’t want to pull in widget the title (just the body). Can anyone show me where WordPress is pulling in the Title?

e.g. At the moment I have…

// In my page template...
<div id='advert-header'>        
   <?php dynamic_sidebar( 'Header Advert' ); ?>
</div>

// In functions.php...
function twentyten_widgets_init() {
    register_sidebar( array(
        'name' => __( 'Header Advert', 'twentyten' ),
        'id' => 'primary-widget-area',
        'description' => __( 'The primary widget area', 'twentyten' ),
        'before_widget' => '',
        'after_widget' => '',
        'before_title' => '',
        'after_title' => '',
    ) );
// etc.
}

Related posts

Leave a Reply

7 comments

  1. Widget always have a filter applied on title name ‘widget_title’, use that.

    add_filter('widget_title','my_widget_title'); 
    function my_widget_title($t)
    {
    
        return null;
    }
    

    Thanks

    -Shak

  2. You can try this (in functions.php within register_sidebar)

    'before_title' => '<span class="hidden">',
    'after_title' => '</span>',
    

    And Css

    .hidden{display:none;}
    

    You can also try this.

  3. Those titles can be useful for CMS user, so in your register_sidebar, you can put sth. like I did in code below (works in WordPress 5.0.3). Now widgets title is in html comment, it seems ok for me

      register_sidebar( array(
        'name'          => esc_html__( 'Contact page widgets', 'xxx' ),
        'id'            => 'sidebar-3',
        'description'   => esc_html__( 'Add widgets here to appear on contact page.', 'xxx' ),
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<!-- ',
        'after_title'   => ' -->',
    ) );
    
  4. Is there a title field for the widget you are using?
    You could try just putting &nbsp; in there, so you get a space for the title.
    Not the most elegant solution though.

  5. Please put this code in functions.php file.

    add_filter( 'widget_title', 'remove_widget_title' );
    function remove_widget_title( $widget_title ) {
        return $widget_title == '&nbsp;' ? '' : $widget_title;
    }