How come the markup I specify in the 'before_title' and 'after_title' settings of register_sidebar gets applied to the default text WordPress widget but not one of our custom widgets, when both are in the same sidebar and both have a title in the widget settings?
For example when I set
register_sidebar(
array(
'name' => $name,
'id' => $id,
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">XXXXX',
'after_title' => '</h2>',
)
);
the XXXX appears in the text widget's title, but not in any of our custom widgets.
In the widget method of the custom widgets we do stuff like
$title = $instance['title'];
if ( $title ) {
echo '<h2><span class="text">' . esc_html( $title ) . '</span></h2>';
}
Does this way of rendering the title override any settings you put in register_sidebar?