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.
}
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.
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.
register_sidebar( array|string $args = array() ): string. Builds the definition for a single sidebar and returns the ID.
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' => ' -->',
) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With