My goal here in this tutorial is to teach you how to create a WordPress plugin in a simple and organized way, with a focus on code isolation and consistency. By the time you’ve finished this tutorial, you’ll have a plugin shell created which you can use essentially as a boiler plate template for all of your future plugin ideas.

Before you get started with this WordPress plugin development tutorial, you need to know the difference between a WordPress Theme and a WordPress Plugin. Once you know the difference between a theme and a plugin, and you’re certain that you want to create a plugin. Then, this article is for you.

WordPress Themes

A WordPress theme is typically intended for front-end output only. However, there can be back-end interaction in terms of controlling what the theme does. Just think about the functionality in your theme. Everything in your theme’s directory should be directly related to what the theme does or how it appears (i.e. Theme Customizer or widgets). You shouldn’t necessarily be providing any kind of specific functionality. Once you start to develop specific functionality, you should consider moving this idea of specific functionality into a WordPress Plugin.

WordPress Themes are files that work together to create the design and functionality of a WordPress site. Each Theme may be different, offering many choices for site owners to instantly change their website look.

Why else should you build a WordPress Theme?

  • – To create a unique look for your WordPress site.
  • – To take advantage of templates, template tags, and the WordPress Loop to generate different website results and looks.
  • – To provide alternative templates for specific site features, such as category pages and search result pages.
  • – To quickly switch between two site layouts, or to take advantage of a Theme or style switcher to allow site owners to change the look of your site.

A WordPress Theme has many benefits, too.

  • – It separates the presentation styles and template files from the system files so the site will upgrade without drastic changes to the visual presentation of the site.
  • – It allows for customization of the site functionality unique to that Theme.
  • – It allows for quick changes of the visual design and layout of a WordPress site.
  • – It removes the need for a typical WordPress site owner to have to learn CSS, HTML, and PHP in order to have a great-looking website.

— WordPress Theme Development Codex

If you’re interested in creating a WordPress Theme, please read through the WordPress Theme Developer Handbook or the Theme Development Codex.

WordPress Plugins

A WordPress Plugin is typically some kind of specific functionality which isn’t already available in WordPress out of the box. This could be something exclusive to the back-end, exclusive to the front-end, or a combination of the two. Plugins will continue to provide the functionality across all themes. Plugins are (usually) not theme specific.

A WordPress Plugin is a program or a set of one or more functions written in the PHP scripting language, that adds a specific set of features or services to the WordPress site. You can seamlessly integrate a plugin with the site using access points and methods provided by the WordPress Plugin Application Program Interface (API). — Plugin Development Codex

If you’re interested in creating a WordPress Plugin, please read through the WordPress Plugin Developer Handbook or the Plugin Development Codex.

Creating a WordPress Plugin

Creating your first WordPress plugin can be a bit overwhelming at first. There’s a lot to read about and, quite honestly, it can be difficult to piece all of that information together. My goal here is to hopefully educate you on assembling a really basic plugin, with organization in mind. Organization is absolutely fundamentally key to producing a WordPress plugin. Especially if this is a plugin you plan to maintain over the years to come.

WordPress Plugins Directory

Plugins are located in the ./wp-content/plugins directory of your WordPress installation.

Steps to Create a WordPress Plugin

  1. Name Your WordPress Plugin
  2. Isolate Your Plugin From Other Plugins
  3. Organize Your Plugin Files
  4. Define Directory Paths
  5. Load Plugin Files
  6. Directory Structure
  7. Plugin Activation, Plugin Deactivation, and Plugin Uninstallation
  8. Essential Plugin Files
  9. Security: Protect Plugin Files
  10. Plugin Hierarchy

Leave a Reply