Home    Articles


How to build a wordpress plugin from scratch with minimum features


If you want to build an wordpress plugin from scratch quickly, here are the steps:

…but before please remember these things:

a) The correct way to build a plugin is the wordpress way.
b) Use the wordpress database handler
c) Use wordpress add_action function to import needed files

In this tutorial i will show you how to make your plugin reconizable by the wordpress, you will know how to add a menu item for your plugin in admin area and also you will be able to display a message by clicking your plugin button.

Let’s start

1). The first step is to create a folder into your plugins folder: wp-content/plugins/

Call it “my_plugin”.


2). Now you need to add a php file in this folder. Name the php file exactly like the folder name.
3). Add this code into the php file:

Plugin Name: My first plugin 
Plugin URI: http://www.w3bdeveloper.com
Description: Plugin for testing things
Author: Daniel Halmagean 
Version: 1.0 
Author URI: http://www.w3bdeveloper.com

Now you can see the plugin into your wordpress admin area -> plugins -> installed plugins
Search for “My first plugin”.

You can activate or deactivate your plugin , and also you can see details about the plugin.


4). Now we will add a menu item for your new wordpress plugin

Open the my_plugin.php file and under the plugin details that were added at point 3 add the following code:

 * This function is called when My Plugin button is called
function my_function() 
  #here you can require a php file that will dispplay some data
  echo 'my plugin admin area';
 * This function is called when admin_menu is loaded and will add some menu item that you want
 * add_action('admin_menu', 'menu_items'); will call this function
function menu_items()
	#add menu items
	add_menu_page('My first plugin', 'My Plugin', 'manage_options', 'my-plugin-admin', 'my_function'); /**this will call "my_function" function **/
/** when the menu loads - add menu items */
add_action('admin_menu', 'menu_items');

After adding this code your plugin will know to add a menu item, and to display a message when that button is clicked.
In next tutorials i will show you how you can use wordpress database handler and much more.

This is what you will see in the admin area:


That’s all.

ps: If you are to lazy to do it step by step, you can download this wordpress plugin free from here

…first time posted on w3bdeveloper.com