WordPress has on of the best administration back-ends. Widget is a content area in theme where you can put your functionality as you want. To create a widget in wordpress is very easier, to write your custom widget need little programming experience in PHP.
Wordpress given a great flexibility to the programmer in CMS, you can create great things in finger tips even its plugins, widget and template theme.
This post show you how to create a simple widget and display on your front end.In this tutorial I will create a widget which will take a constant test and display it on your wordpress design are, where you can drag and drop widget to your expected template area.
You can also check other tutorial of wordpress,
- How to Create a Simple WordPress Plugin
- How To Create Widget in WordPress
- How to Add Setting Page in WordPress Plugin
It’s same as wordpress plugins except registering as widget_init action.
We will start first create a directory
wp-content/plugins directory.Now we will create a test
test_widget.php file where we will keep all the widget functionality code.
Create Structure of Widget :
We will put below code in
test_widget.php at top level.
/* Plugin Name: Test Widget Description: Test widget Author: Parvez Alam Version: 1.0 */
Above codes tells wordpress compiler this file is widget.
Add code functionality :
This file responsive to all widget level functionality.
How to Activate Plugin:
Now open installed plugin menu in dashboard menu and click activate link of widget plugin.
After activation widget,you can view in widget list of theme.
Front End Area :
Now you can view final result in wordpress front end.