In order to create a WordPress plugin, you first need to create a PHP script and place it in the proper location for WordPress to recognize it as a proper WordPress plugin.
Location of WordPress plugin scripts
If you installed WordPress in your document root, WordPress plugins would go here:
/home/userna5/public_html/wp-content/plugins
If you installed WordPress in a sub-directory called /blog, this would instead be:
/home/userna5/public_html/blog/wp-content/plugins
Adding your WordPress plugin PHP script
Now that you know the location of your WordPress plugin scripts on the server. Simply use FTP or the cPanel File Manager in order to upload or create your WordPress plugin PHP script.
Create WordPress plugin directory
You’ll want to create a new folder for your plugin first. This folder can simply be named the same as your plugin name. In my case I’ve created a folder called /extra-post-info, so my full path to my plugin is now:
/home/userna5/public_html/wp-content/plugins/extra-post-info
Create WordPress plugin PHP script
Now that you’ve created a folder for your WordPress plugin PHP script to go into, you want to create the PHP script that will control your WordPress plugin, and place it in the folder you created.
I’ve simply uploaded a PHP file to my newly created plugin directory, and called it extra-post-info.php:
/home/userna5/public_html/wp-content/plugins/extra-post-info/extra-post-info.php
In the extra-post-info.php script, I’ve placed the WordPress plugin File Header info for the plugin I’ll be creating:
<?php /* Plugin name: WordPress Extra Post Info Plugin URI: https://example.com/wordpress-extra-post-info Description: A simple plugin to add extra info to posts. Author: Jacob Nicholson Author URI: https://InMotionHosting.com Version: 0.5 */ ?>
Accessing WordPress plugin script via WordPress dashboard
Now that you have a PHP script with WordPress File Headers inside of your WordPress plugin directory. Next login to the WordPress dashboard and click on Plugins to see your newly created plugin:
Create WordPress plugin function
With your WordPress plugin script started, the next step will be to create the WordPress plugin function that actually contains the logic of what your plugin will do.