Home All you need to know about the Legacy Widget block in WordPress Gutenberg All you need to know about the Legacy Widget block in WordPress All you need to know about the Legacy Widget block in WordPress

All you need to know about the Legacy Widget block in WordPress

November 15, 2023
All you need to know about the Legacy Widget block in WordPress

The Legacy Widget block enables users to add, and preview third-party widgets registered by plugins and widgets created using the good old Widgets Editor.

Third-party widgets can be added by inserting a Legacy Widget block and choosing the widget from the block’s menu.

Third-party widgets can also be inserted by searching for the widget’s name in the block inserter and choosing it. A Legacy Widget block variant will be inserted.

The message “No preview available” is shown.

When the Legacy Widget block is not chosen, a preview of the widget will be displayed.

When the widget’s widget() method does not produce anything or simply returns empty HTML elements, the Legacy Widget block displays a “No preview available.” message.

All you need to know about the Legacy Widget block in WordPress

If you think your followers would appreciate this content, hit that tweet button.

When a preview should not be presented, widgets can take advantage of this by returning early from the widget().

Migration to a block

You can make it simple for users to move a Legacy Widget block containing a specific widget to a block or many blocks. This enables plugin developers to replace widgets with blocks that are more straightforward and can be used in more locations.

You may use the Legacy Widget block in other block editors

You may enable the Legacy Widget block in other block editors, such as the WordPress post editor if you like. This feature is not activated by default.

First, make sure that any legacy widget-required styles and scripts are loaded onto the page. A simple method to accomplish this is to manually execute all of the hooks that are normally executed when a user navigates to the widgets’ WP Admin panel.

WordPress 5.8 Block Editor Changes

The Gutenberg changes are at the top of the list. You may now change Widgets to incorporate Gutenberg blocks, and the Theme Customizer (located under Appearance – Customize) allows for block inclusion as well. This is a big deal because widgets and the theme customizer were formerly the sole provinces of plugin/theme authors. Alternatively, specialist themes like Divi offer theme builders that allow for non-content-area modification (which are nonetheless more powerful than Gutenberg‘s newest choices).

Block Widgets

The interface is identical to that of the Post or Page editor. Enter the customizer’s Widgets area and hit the + button. You will select a block or blocks from the menu and interact with them in the same way that you would with any other piece of content.

All you need to know about the Legacy Widget block in WordPress - Block Widgets

You continue to have access to your current widgets. WordPress currently refers to them as Legacy Widgets. Simply navigate to Appearance – Widgets, and the new Legacy Widgets block will provide a selectable list of what you have installed. Installing the Classic Widgets plugin will also allow you to disable the new block widgets. That maintains things the same as they’ve always been.

The Classic Widgets plugin disables the Block-Based Widgets System in WordPress 5.8.

Classic Widgets is a fundamental plugin for WordPress. Tonya Mork and Andrew Ozz, two core contributors, built the plugin under the WordPress Contributors account. It enables users to turn off the future block-based widgets system. According to the plugin description, support will be provided until 2022 or for as long as necessary.

Widgets eventually will become a legacy feature in the future. They are, however, not going away any time soon. Users and theme developers may occasionally require smaller stepping stones as they migrate from the pre-block period of WordPress to the ultimate inclusion of all the sub-components of FSE. Block-based widgets provide users extra options to interact with blocks outside of the post-content area without plunging headfirst into a complete block-based experience.

What does the introduction of Block-Based Widgets mean for Theme Developers?

Traditional widget HTML wrappers are not available for block-based widgets. As a result, themes will be unable to identify the new block-based widgets as widgets and design them correctly.

The wrapper element for a widget and its name are typically searched for by themes when creating style. Control over the look of a widget is taken away from theme designers and handed to users in the absence of widget wrappers.

Because widget blocks lack a common class name that theme developers may target with CSS, they are unable to provide end-users with a uniform style for all of their widgets.

While this new structure offers the end-user creative flexibility over how their widgets look, it removes the ability to have detailed widget styles from a theme applied to your widgets automatically.

Useful links

Was this article helpful?