Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
}
like image 501
SparrwHawk Avatar asked Feb 24 '12 09:02

SparrwHawk


People also ask

How do you call a dynamic sidebar in WordPress?

WordPress uses a function called dynamic_sidebar() to call your sidebar into your theme. You may use either the id or name to identify which sidebar you want, but id is more reliable. If you do not name which sidebar you want to call, WordPress will call the first one that is registered in your theme.

How do I create a sidebar in WordPress without plugins?

With Custom Sidebars, you get the job done all in your dashboard's Appearance → Widgets section. This is where you can add a new widget area (by clicking on “+ Create new sidebar“) and then set its display logic by clicking on Sidebar Location.

What method is used to register sidebar in function PHP?

register_sidebar( array|string $args = array() ): string. Builds the definition for a single sidebar and returns the ID.


1 Answers

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'   => ' -->',
) );
like image 82
TMMC Avatar answered Sep 19 '22 15:09

TMMC