Widgets

WordPress widgets build it simple for you to add extra functions to your website through a very simple drag-and-drop interface.

  • By default, WordPress comes with a few basic set of widgets.

wordpress-default-widget

Also, WordPress allows you to create your own custom widgets with an advanced level of access that doesn’t come with default widgets.To create a custom widget to your WordPress dashboard, follow these simple steps

Creating Custom widget

In WordPress, You can create a custom widget using the WP Widget class. In that, we will use minimum 4 functions to create a custom widget.

1. __construct(): This function provides the basic widget information.

2. widget(): This function contains the widget output.

3. form(): This function defines the widget settings displayed in the WordPress dashboard.

4. update(): This function updates the widget settings in the database.

You can create a custom widget by adding the following code to the functions.php file.

Now, Go to your WordPress Widget area, there you can now find your new custom widget created as shown below.