Andy Tran

How to create a wordpress custom widget?

by | 24 Jul, 2020 | Wordpress | 0 comments

How to create a WordPress custom widget

What Are WordPress Widgets?

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

  • As shown in the below image, WordPress includes a few basic widgets by default.

default widget functions

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 for 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.

Widget code

In the above code, we have defined a new function called new_custom_widget(). It registers our widget using the widget ID, which is specified in the __construct() function.

Next, we have tied this function to widgets_init, which loads the widget by using WordPress’s add_action() method.

Now you can use the newly-installed widget.

  1. Go to the Appearance menu, and select Widgets. You should see a widget named Custom Widget in the Available Widgets list.
  2. Next, drag the widget and drop it in the Footer section on the right side of the page as shown below.

widget setting

Here are more blogs on WordPress

  1. Custom Logo WP Login Page
  2. How to change WordPress login URL without plugin
  3. How to create a wordpress custom widget?

Looking for a top IT consulting services provider specializing in salesforce consulting, mobile app development, and web application development? Choose Erudite Works. We offer cutting-edge technology and engineering solutions for businesses, trusted by millions of users daily. Contact Us.

Share this article...

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.