Website Guider

The Ultimate Resource for WPadmins and Geeks

WordPress Plugin Basics: Custom WordPress Plugin Developement

Official docs of WordPress defines plugin as:

WordPress plugin is a PHP file with a WordPress plugin header comment.

If we dig deeper into the meaning of plugin, we can say that “It is the tool, which helps us to insert and improve our website by doing some little work”.

In this article, I am going to show you what are the basics and how we can create a custom WordPress plugin.

Remember you, I have created a plugin Related Posts for Genesis and I will use the code of that plugin in this tut and will explain it briefly.

Be ready, We are going to jump into the sea of WordPress Plugins.

Why Should I Learn to create Plugins

Someone has rightly said:

Change is the law of nature.

Of course, there is no object in this universe which is quite static and unchanging. The bloggers and developers needs also change as per requirements.

The WWW is a giant place and everyday is new day, everyday new features come and old ones fade.

If you are the blogger using WordPress, you can simply change the whole working of your website by creating the plugin.

You should be always prepared to face any task or any challenge. By taking the time and changing nature in mind, you should learn to code WordPress plugin.

What Things Should I Know Before Diving In The Sea

In order to code a plugin, you must have some knowledge of the web languages. The web languages you need to know are:

  1. HTML: This is the very basic language every plugin developer must know. Because, the HTML is the building block of the web.
  2. CSS: This one is also a must know language because CSS is used to design the web.
  3. PHP: You can’t create a WordPress plugin without knowing PHP. WordPress is written in PHP, so plugins must be written in PHP. You should have a well understanding of PHP otherwise you can’t create even a simple plugin.
  4. WordPress Plugin API/Hooks: If you don’t know anything about this, please don’t start to write a plugin. It is also must, you can find more about it here. https://codex.wordpress.org/Plugin_API/Hooks

The above mentioned things are important for plugin development. If you don’t know even one of them, don’t start writing a plugin and also reading the article.

Basics of WordPress Plugin Development

In this section we look at the basics of WordPress plugin development which are musts.

Creating a Folder

The purpose of creating a folder is that the code of the plugin will be kept separately and can be edited easily when doing changes. So where to create the folder and what will be stored inside it.

Let’s create a folder for our plugin in the plugin directory.

Go to the core files of WordPress. There you will find a folder named as wp-content and inside it you will notice a folder named as plugins.

Now create a folder inside it and name it as test.

Inside the folder, you can store files, images, videos or anything which is necessary for your plugin. Also, you can create sub folders in it.

Creating a File

Inside the test folder, create a file and name it test.php. Inside it we will insert this data.

<?php
   Plugin Name: Test
   Plugin URI: https://websiteguider.com
   description: Test Plugin
   Version: 1.0
   Author: WebsiteGuider
   Author URI: https://websiteguider.com
   License: GPL2
?>

I added many things like the name, version, author. All this data will be shown in admin section.

If you go to admin section and see, there you will find that plugin is there. But our plugin is empty, so it would do anything necessary.

All this was a short journey. You can add more and more folders and files and can write more code inside it in PHP.

The above-mentioned things were some very basic things which are must to do parts.

Hooks

Hooks are the parts of the WordPress and should be consumed by every plugin developer.

If we want some unique behaviour from our code, the hooks come into play like activation and deactivation hooks. You can take full benefit of them.

API’S

API’S make writing code simpler. you don’t have to code lots of things. WordPress has some built in API’s which can help developers to code the plugin in few hours.

I hope this tut helped you. If so please do share with your friends. Thanks.

Raashid Din Dar

Raashid Din Dar is a web developer and designer. He specialises in WordPress Theme and Plugin development. Also, Web Designing is what he loves.He loves to read books and play with friends.

Leave a Reply

Your email address will not be published.

Back to top