Chapter 10: Adding New Widgets to the WordPress Library
Widgets have been present in WordPress from the early days of the platform. They allow users to easily populate sidebars or other widget areas of their website theme with content that is provided by WordPress itself (post or page data) or by any plugins that have been installed (for example, book review system information). Starting with the recent version 5.8, WordPress introduced the ability to use blocks from the block editor in the widget area. That being said, the platform continued supporting legacy widgets, coded using a combination of PHP and HTML. In the subsequent version 5.9, WordPress introduced the concept of block themes, with the first example theme not supporting widgets. We can therefore say that the future of widgets is a bit uncertain, but they are still relevant to the large majority of site themes out there today.
This chapter shows how to use a widget class to create a custom content widget. It also covers...