WordPress Plugin creation
Minimal Setup of a Plugin Folder and Files[edit | edit source]
First step of creating a plugin is creating the folder and file which the plugin will load from.
Plugins are located in
The WordPress standard is to create a folder and filename that mirror each other like so:
After creating your plugin file you need to start your plugin with a
Plugin Header. This allows WordPress to scan your plugin file and store the meta data about the plugin, and allow users to use this and determine if they want your plugin active, or inactive. Copy this template into the top of your main plugin file you created, and modify it as needed:
<?php /** * Plugin Name: PLUGIN-NAME * Plugin URI: HTTP-LINK-TO-WEBSITE-PLUGIN-PAGE-OR-REPO * Description: BREIF DESCRIPTION - KEEP IT SHORT * Author: WORDPRESS-DOT-ORG-USERNAME * Version: 0.0.1 * Author URI: HTTP-LINK-TO-MAINTAINER * License: GNU General Public License v2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.html * Text Domain: short_prefix */ // Begin custom PHP WordPress plugin work
Note that WordPress plugins should typically be licensed as GPL. Licensing should not be discussed as part of this topic though.
At this point, you should already by able to see your new plugin in the WordPress Admin area. In a standard setup you would locate this area at
/wp-admin/plugins.php. Go ahead and activate your plugin, and you are ready move into the next steps of building your plugin!
Just to end our example on something actionable, you could now add the following to the bottom of your plugin file:
die('My custom plugin is loaded : '. __FILE__);
Refreshing your site after this change should result in all pages printing this text. Never do this in production (live) sites, and always remember to take this back out before continuing.