Create Custom WordPress Plugin

Create a custom WordPress plugin from Scrach

To create a custom WordPress plugin follow these steps:

1:- Create Plugin Directory

First create you plugin directory inside wp-content/plugins folder. For reference using my-custom-plugin

mkdir wp-content/plugins/my-custom-plugin && cd wp-content/plugins/my-custom-plugin

2:- Create Plugin File

Now you have to create a plugin file with the same name as plugin directory

touch my-custom-plugin.php

3:- Setup Plugin Code

Place the following code at the top of plugin file.

/**
 * Plugin Name: Name Of The Plugin
 * Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
 * Description: A brief description of the Plugin.
 * Version: The Plugin's Version Number, e.g.: 1.0
 * Author: Name Of The Plugin Author
 * Author URI: http://URI_Of_The_Plugin_Author
 * License: A "Slug" license name e.g. GPL2
 */     	

4:- Start Writing code

If you want to create some user defined function create functions.php and include it on main plugin file. like add_shortcode, add_menu_page, add_submenu_page,
add_action

touch functions.php
include_once "functions.php"; 

To interact with database use following code.

global $wpdb;

Now go to admin and activate your plugin. Your plugin is ready to work

Leave a Reply

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