0

I've never seen this issue before, so it could either be a mistake on my part, or a very recent change to WP core, but either way it doesn't make sense for me.

Like usual, I register widgets like I always have:

// Register Widgets
function pr_widgets_init() {

    register_sidebar(array(
        'name'          => 'Sidebar',
        'id'            => 'sidebar-widgets',
        'before_widget' => '<div id="%1$s" class="bg-light rounded p-4 mb-4 widget-container %2$s">',
        'after_widget'  => '</div>',
        'before_title'  => '<h3 class="h5 mb-3 text-primary"><span class="border-bottom">',
        'after_title'   => '</span></h3>',
    ));

}
add_action('widgets_init', 'pr_widgets_init');

And then place on the template the same way I always have again:

if(is_active_sidebar('sidebar-widgets')) {
    dynamic_sidebar('sidebar-widgets');
}

However, there is no title on the front end for any of the widgets, even when looking at the page source.

What's more, when viewing them in WP-Admin (where it visually previews it), there are no titles showing here either.

enter image description here

enter image description here

Is this a WP bug, or have I completely missed something out? There's no option in the widget editor to add a title, or change the title either.

Would be very grateful for any help, tips or ideas at this point.

1 Answer 1

1

WordPress 5.8 added the ability to add Blocks to sidebars. Blocks do not use the title and markup defined for a sidebar. They just use the normal HTML they would use in the editor. “Legacy” widgets can still be added, and should still have the option to enter a title and use the markup defined for that widget area.

WordPress is moving towards using blocks for everything, so some of this behaviour will change. The “new” way to handle this use case might be to create a wrapper Block that has a title field and an area for adding blocks. Or you could just use heading blocks.

5
  • That's very dissatisfying. Not only will using the heading block ruin the way I'm adding classes to these headings, but it also treats them as individual widgets. Why would they introduce this knowing it will break many people's sites and styling? There was nothing wrong with how it was.
    – Lee
    Sep 14, 2021 at 11:40
  • However, what's more interesting is that I've found this just now, that seems reasonably recent (5 weeks ago): core.trac.wordpress.org/ticket/53920
    – Lee
    Sep 14, 2021 at 11:41
  • It won't break any existing widgets or styling. They function as normal. The update just means that users can add new elements that don't adhere to the styling of existing widgets. Sep 14, 2021 at 12:24
  • I disagree, if they've suddenly removed widget titles from three core widgets (at least three), then that's a break of styling and appearance.
    – Lee
    Sep 14, 2021 at 12:56
  • But thank you for your answer, that has at least answered my question.
    – Lee
    Sep 15, 2021 at 9:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.