How to Create Custom WordPress Plugin: 3 Easy Steps
A custom plugin is an alternative method of storing functions for your website. WordPress is so popular because of its open-source content management system (CMS) and there are over millions of plugins widely available but we will see how to create plugin in WordPress with examples and adding custom codes instead of using a function.php file
Table of Contents
Reason to avoid function.php file
You can also include additional code in the theme’s functions.php file but whenever there is a theme update or switching to a different theme in the future, you will lose these changes(additional codes). And every time you must back up your custom codes whenever there is a theme update.
To avoid such a problem, you can create your own plugin and use custom code in that. Benefit – The theme update won’t affect the plugin code.
Now, we will see how to create plugin in PHP (text file) and add it in WordPress.
How to Create a WordPress Plugin (In 3 Steps)
Recommendation – It is best practice to create a new Plugin in the local environment first and after successful testing deploy it in the live environment.
Let’s look at how to create a plugin for a website from scratch in 3 steps
Step 1: Create the Plugin File
Open a new Notepad or text file.
Provide basic information for a new plugin, mentioned below:
Plugin Name | any name, e.g., MyPlugin |
Plugin URI | give your URL, e.g., https://google.com/ |
Description | Short note |
Version | any number, e.g., 1 |
Author | any name |
Copy & paste the below code into the notepad. Code should start with <?php
<?php
/*
Plugin Name: MyPlugin
Plugin URI: https://google.com/
Description: My custom functions
Version: 1
Author: Myself
*/
Save the file, example – MyPlugin.php.

– go to ‘Send to‘
– click on Compressed (zipped) folder.

Step 2: Install Custom Plugin into WordPress
1. Go to WordPress admin (https://www.yoursite.com/wp-admin)
2. go to – Plugin >> Add New
3. Click on ‘Upload Plugin‘
4. ‘Choose file‘ and upload the zip file (MyPlugin.zip)
5. Click on ‘Install Now‘
6. After successful Installation, click on ‘Activate Plugin‘
Click on Plugins, you can see the newly created custom Plugin with the description as shown in the below screenshot.

Step 3: Edit Plugin & Add Code
Next, go to Plugin >> Plugin File Editor
On the top-right, select the custom plugin ‘MyPlugin‘ from the dropdown and click the ‘Select‘ button.

Write your php code in the editor and click on ‘Update File‘
That’s it, test your code if it is working as expected.
Reference: WordPress