Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Here you learn What is WordPress Widget, How to add Custom Widget in WordPress, Different types of Widget areas in WordPress, and many more.
What is WordPress Widget
A widget is a small piece of code or a plugin that inserts a piece of information in your site’s sidebar. This information can be anything from a list of search engines to a list of product categories, lists of the latest news, and other things.
Widgets extend the capabilities by allowing you to easily distribute content across your websites. In fact, the term “widget” was created and used by Apple for their Dashboard widgets.
The use of widgets in WordPress has been popularized by Akismet, a spam blocking plugin, which calls itself a community-powered defense against comment and trackback spam.
How to Add Custom Widget in WordPress
1. Login to your Site Dashboard
2. Go to Appearance -> Widgets.
Scroll down the page and you see two sections named ‘Available Widgets’ & ‘Widget Area’.
3. Choose Widget You Want to Add
In that section, you see many widgets. After choosing a widget you want to add to your site.
Now click on Edit Widget Option & show your widget in the sidebar or Homepage Widget area of the page.
After that click on Add Widget.
If you want to edit your widgets then you can do that too without any problem because it’s the easy way ever for editing widgets.
Note:- If your Widgets area looks different, then Install Classic Widgets from WordPress Plugins Directory.
If you want to add Custom Widget on WordPress then,
First off, the way widgets work with WordPress is that you put your PHP code into a special “PHP” widget area near the top of one of your sidebar template files (either sidebar.php or sidebar-alt.php).
If you don’t have any existing widget areas for your sidebars in the current theme, or if you don’t want to edit an existing widget area and instead would like to put your PHP code inside a custom widget area, then you will need to open up the functions.php file in your active theme (usually found in the /wp-includes/theme folder) and add this function:
<?php register_sidebar() ?>
This function is the standard WordPress way of registering a new widget area (called “sidebars”) for you to use in your blog.
The register_sidebar function will give you two arguments when it runs: the name of the sidebar you are registering, and an array of information about that sidebar which includes things like the id and class attributes for that sidebar, as well as an area where you can put any custom PHP code.
If you want to use a custom widget area for your new phpsidebar1 , then just open up sidebars-alt.php (found in your active theme folder – usually /wp-content/themes/theme-name/sidebars-alt.php ) and add this line above the PHP code in your widget area:
<?php if (function_exists(‘phpsidebar1’)) phpsidebar1(); ?>
This will make a new sidebar called “phpsidebar1” for you to put custom PHP in.
You can do this with as many widget areas as you want, so if you wanted to create another sidebar called “phpsidebar2” you would open up sidebars-alt.php and add the following line above your php code:
<?php if (function_exists(‘phpsidebar2’)) phpsidebar2(); ?>
The way this works is actually quite simple. The function_exists function checks to see if there is a special hook created for the phpsidebar1 or phpsidebar2 functions somewhere in your theme files. Each time you add a “phpsidebar” widget area, WordPress will automatically create this new special hook for you.
How to Edit Widget Code in WordPress
1. Go to Appearance -> Widgets
2. Choose Widgets You Want to Add
After choosing a widget you want to edit, click on the Edit Widget Option.
3. Edit Your Widgets
Now you can change your widget title & if you want to edit the tag line of the widgets.
You find different options to edit depending on widgets.
A small popup appears for the updated successfully message, and also see your updated widget in the sidebar or footer area of the page Also we will get an updated widget code in our text editor.
Note:- If you do not find Edit option on Widgets, then click on “Enable Accessibility Mode”.
WordPress widgets not showing in admin
Sometimes you will find that the widgets are not displayed in the Widget Area or no widget options are shown on your page.
1) To remove any existing widgets, go to Appearance -> Widgets.
2) Under Available Widgets, click on Screen Options at the top.
3) Tick all boxes except for ‘Widgets Title’
4) Now click on ‘Screen Options’ to save your changes.
5) All widgets should be hidden now.
6) Refresh the page and take a look at the right-hand side of the screen, where you will see that there is an option called ‘Widgets Title’.
7) Unchecking this box will allow you to see all the widgets again.
8) Click on ‘Screen Options’ to save your changes.
Different types of widget areas in WordPress
1. Sidebar widgets area
Sidebar is created by default when you install a fresh copy of WordPress on your site. By default, it contains 5 widgets with titles Primary Menu, Secondary Menu, Archives list, Blogroll, and Search box.
It is created by adding ‘Footer Widget’ in the below of the Sidebar widget, and also you can add two more widgets in this footer section.
3. Header widgets area
This header widget allows you to display custom text or HTML content in your blog’s top section. This widget helps you to show the site title, slogan, or any other content in the header section of your site.
4. Posts widgets
With the help of this widget, it is very easy to display posts by custom taxonomy, category, date, and author.
5. Search box Widget
This widget allows you to add a search facility in your blog’s sidebar area.
This is a new feature in WordPress 4.0, which will help you to add images without using any plugins.
WordPress Widget List
1. Recent Posts Widget:- It shows the post of your site on the home page.
2. Featured Image Widget:- This widget allows you to add a featured image from any post or page in your blog.
3. Author Widget:- In this widget, it is very easy to display posts by the author and also uses the new WordPress 4.4 user interface.
4. Social Media Widget:- It will display Facebook and Twitter share buttons on your site.
5. Ad space (300*250):- This widget allows you to add text or image ads in your blog sidebar, so it can monetize your blog through Adsense or any Google Ads alternative.
6. Text Widget:- You can add any HTML or text in this widget, that is supported by your browser’s CSS. So it has no limit to using this widget.
7. Recent Comments:- This widget helps you to display the most recent comments in a post or any page in the sidebar of your site.
8. Subscribe Widget:- Subscription form in the sidebar of your site, helps you to gain subscribers and increase your blog traffic.
9. Random Posts Widget:- By using this widget, you can display a random post in the sidebar of your site.
Widgets Vs Plugins
There’s a lot of debate about the difference between widgets and plugins which is increasingly confusing for WordPress users.
You can think of widgets as small reusable snippets of code that are either in-lined into your theme or placed in their own file. Plugins are larger, more complex pieces of code that usually do one thing (such as adding social icons).
You’d be forgiven for thinking that widgets and plugins are the same things, but they’re actually not. They share a lot of similarities but also have several very important differences.
Let’s explore some of the key differences between widgets and plugins.
Here are 25 differences between Widgets vs Plugins:-
1. Widgets are specifically designed for displaying additional content in your site template. Plugins can do other stuff as well e.g Akismet also has a function to stop spamming.
2. You need to install a plugin first before widgets can be added, whereas you usually just activate a widget instantly after it has been added.
3. You are likely to get more options in a widget than you are with a plugin.
4. Plugins aren’t dependable on specific template files. They just need WordPress core code, whereas widgets often rely on specific template files of your theme in order for them to work properly.
5. Widgets can be added in various locations (sidebars, footers, etc.) but you can only add plugins in specific locations (such as a header or footer file).
6. A plugin can be activated and deactivated without having to edit the source code of your website. Widgets may need some changes made to template files if there’s more than one instance of a widget on a page.
7. The Plugin API is a crucial WordPress feature because it’s what makes the platform so extendable. However, if you need a simple piece of functionality that doesn’t require any complex programming then widgets are a great way to achieve this.
8. You can have as many plugins as you want to be installed on your site but there’s a limit to how many widgets you can have. The default theme comes with three sidebars that are already set up as widget areas, but you can add more using plugins or by adding code to your template files.
9. It’s easier to change the location of a plugin on your site because it usually resides in one file whereas if you want to change the location of a widget then you’ll need to edit template files.
11. Plugins aren’t loaded with every page request whereas widgets are. This means that by default plugins are likely to be faster than widgets because they don’t have the overhead of loading all the time.
12. A plugin will stop running when your site is deactivated whereas a widget may need its code edited when switching themes.
13. You can upload a plugin or a widget to your site, but widgets are easier to manage.
14. With plugins, you’ll need specific programming knowledge whereas you can make modifications to widgets without knowing anything about coding.
15. Plugins don’t always work with responsive themes because they usually load within the content area of a template file whereas widgets often do not.
16. Plugins are more complicated than widgets so it’s best to keep them to a minimum. Widgets are easier for less experienced users to interact with.
17. Each plugin runs in its own memory space, which means that if one crashes then it won’t take others down with it. This also means that plugins can conflict with each other. Widgets run within the context of WordPress so if one crashes then it can take your site down with it.
18. Plugins are activated on a per-theme basis whereas widgets don’t have this limitation because they are usually placed in specific locations of your theme.
19. Plugin code isn’t copied to every page request so it’s less likely to slow down your website than widget code.
20. It’s easier to modify plugin behavior than it is with widgets because their files are usually stored in the wp-content directory.
22. Plugins can be moved to any directory, whereas widgets usually reside in their own folder within the wp-content directory.
23. It’s best to keep the number of plugins to a minimum for security reasons, whereas you can add as many widgets as you want without having any negative effects on your site.
24. If you don’t use a plugin for a month then it’s best to deactivate and delete it because it will continue to load on your site. With widgets, you can leave them activated without any problems.
25. Plugin code can be added directly to your template files, but widgets should always go in widget areas.
What is WordPress Widget area?
WordPress Widget area is the right-hand or left hand or both-side sidebar on your site. Here you can see a list of widgets that you can add to display different features in a blog.
What is meta in WordPress Widget?
Meta in WordPress Widget is the title, URL, and description of a specific widget.
What is Text Widget WordPress
It is a simple widget that you can use to add any text or HTML code to your blog.
What is fixed widget in WordPress?
It is used to show any information related to your sites, like copyright information or anything else.
What is WordPress widget class?
By default WordPress has five classes for widgets: WP_Widget, WP_Widget_Factory, WP_Widget_Customize, WP_Widget_Archive and WP_Widget_Pages.
What is register_widget in WordPress?
register_widget() adds a widget to the Widgets API. It is used within class-wp-widget.php, around line 637 in version 2.8.2 of WordPress. The register_widget function takes three arguments: $widget_class , $name and $args.
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.