WordPress Widgets: Why to Use?

If you purchase through a link on our site, we may earn a commission. Learn more.

In WordPress development widgets help developers create functionality within a website. For instance developers can easily add content and features to the sidebars. Now widgets can be used in different parts of a website and these are popularly known as the wigetised area.
Table of Contents
WP Engine High Performance Hosting
BionicWP Hosting

In WordPress development widgets help developers create functionality within a website. For instance developers can easily add content and features to the sidebars. Now widgets can be used in different parts of a website and these are popularly known as the widgetised area.

When you install WordPress there are many default widgets that it comes along with such as post categories, tag clouds, navigation, search, etc. These shouldn’t be mistaken with plugins as plugins often add their own widgets. They were initially designed to give developers a simple and easy-to-use way of giving design and structure to the site. Since they require no coding skills they have become very popular with WordPress users.

Widgets can have variety of functionality ranging from displaying static text to fetching data from an external source or connecting you to the social media. You can easily access widgets in the WordPress Administration Appearance > Widgets panel. You can simply drag and drop the widgets to the website making it very easy for you to make use of widgets.

Apart from this you can also add, remove and rearrange them according to your needs. The order and placement of these widgets is set by the WordPress Theme in the functions.php file. Some widgets would offer you the option of customization in terms of their features, size and optional images.

Advantages of Using Widgets in WordPress

  • Widgets allow you to add advanced level of functionality to a website that adds to its appeal among the users.
  • In most cases widgets are highly customizable allowing you to achieve functionality to meet the niche demands of your business.
  • Widgets can be installed into a WordPress site without having to write a single line of code. This makes it very popular with the average WordPress users who may not possess coding expertise.
  • They are constantly updated and are in sync with the latest demands in the market. You can thus trust on the widgets to keep your website up-to-date.
  • You can also have two customized versions of the same widget running on the website. These widgets can be customized to achieve distinct functionalities in a website.

We have looked into the advantages of using widgets in our website and now we shall take a look at some of the basic functions involved with using a widget in your WordPress site.

Add Widgets in your WordPress Admin

Let us now take a look at the process involved in adding widgets to your website.  If you have opted for a default WordPress installation the core WordPress installation itself comes with some widgets that can be used directly. As mentioned earlier you need to go to Appearance > Widgets and you will see the registered widgets for your site upon default installation. Here on the right hand side of screen you can easily add the settings on to your widgets.

Creating a Widget

WordPress also allows you to create widgets to meet the custom needs of your business. A professional developer can easily make use of this feature to achieve custom functionality in the website. Here we shall develop the widget that displays the latest registered users of your WordPress site. For this we shall create a class that shall derive from WP_Widget that provides the functionality to create a widget.

class Latest_Registered_Users_Widget extends WP_Widget {

public function __construct() {

parent::__construct(

‘Latest_Registered_Users_Widget’,

‘Latest Registered Users Widget’,

array( ‘description’ => ‘This Widget displays the latest registered users’ )

);

}

public function widget( $args, $instance )

{

}

public function update( $new_instance, $old_instance )

{

return $new_instance;

}

public function form( $instance )

{

}

}

Here you can see that we have created a class Latest_Registered_Users_Widget that derives from WP_Widget and it overrides some of the functions.

Registering A Widget with WordPress

Once you have created the widget you can register it with the WordPress to ensure that it shows up in the widgets list in the WordPress admin. This will allow you to drag and drop the widget to the widgetised area on your WordPress site. This involves a single line of coding that we shall mention below.

add_action( ‘widgets_init’, create_function( ”, ‘register_widget( “Latest_Registered_Users_Widget” );’ ) );

You can clearly see that in the above example we are making use of the  widgets_init hook of WordPress and then calling register_widget function on our widget. If everything goes according to play you shall be able to see your widget in the WordPress admin area.

WordPress is the most popular content management system in the world. Among the many factors that have led to the success one of them definitely has to be Widgets. It eases the process of development in WordPress and adds to the fun in achieving features and functionality in your website.

If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.

Alyona Galea

Alyona is a WordPress enthusiast, focused on sharing interesting things she comes across during her work with this great CMS. She loves exploring new destinations and maintains a travel blog at www.alyonatravels.com

Discover more from our archives ↓

Popular articles ↓

One Response

  1. I will use all WordPress Plugins for my website after reading whole blog,Wordpress plugins provides all marvellous benefits.

Share Your Thoughts

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

Claim Your Free Website Tip 👇

Leave your name, email and website URL below to receive one actionable improvement tip tailored for your website within the next 24 hours.

"They identified areas for improvement that we had not previously considered." - Elliot

By providing your information, you'll also be subscribing to our weekly newsletter packed with exclusive content and insights. You can unsubscribe at any time with just one click.