How Do I Create a Custom WordPress Plugin From Scratch?
If you’re new to WordPress development, creating your own plugin can feel intimidating. It sounds like something only “real developers” do.
The truth is much simpler.
A WordPress plugin is just organized PHP code with a purpose. And if you’ve ever added code to functions.php, you’re already closer than you think.
In this article, I’ll show you how to create a custom WordPress plugin from scratch, using a very small, front-end-focused utility plugin. No frameworks, no complex tooling, no unnecessary abstractions.
This is Part 1 of a mini-series aimed at absolute beginners.
Why I Started Creating Custom WordPress Plugins
I didn’t start building plugins because I wanted to.
I started because existing plugins couldn’t solve my problem.
At first, I did what most beginners do:
- Installed multiple plugins that almost worked
- Added snippets to
functions.php - Tweaked themes to force things to fit
Eventually, it became clear that my site’s behavior depended on fragile, scattered code.
That moment led me down the path of building custom plugins — a path that later resulted in premium plugins like LocalBusiness Schema Pro, WooPress License Hub, and Easy DragDrop Uploader Pro.
But every one of those plugins started the same way:
As a small, focused utility plugin.
That’s exactly what we’re building here.
What a WordPress Plugin Really Is (Beginner Mental Model)
Let’s remove the mystery.
A WordPress plugin is:
- A folder
- With at least one PHP file
- That contains a special comment header
That’s it.
There’s no requirement to:
- Use object-oriented PHP
- Create admin pages
- Add settings screens
- Write thousands of lines of code
In fact, the best plugins usually start small.
When You Should Create a Custom Plugin
You should consider creating a plugin when:
- The functionality is not purely visual
- The behavior should survive theme changes
- The code is reused across pages or sites
functions.phpstarts feeling risky
Here’s the mindset shift that changed everything for me:
Themes control appearance. Plugins control behavior.
Once you understand that, plugin development becomes obvious — not scary.
Step 1: Create the Plugin Folder
Go to your WordPress installation and navigate to:
wp-content/plugins/
Create a new folder:
frontend-utility-plugin
Naming matters.
Renaming a plugin later affects updates, branding, and user trust. I learned that lesson the hard way.
Step 2: Create the Main Plugin File
Inside the folder, create a file named:
frontend-utility-plugin.php
Add the following code:
<?php
/**
* Plugin Name: Frontend Utility Plugin
* Description: A small front-end focused utility plugin.
* Version: 1.0.0
* Author: Rey C
*/
defined( 'ABSPATH' ) || exit;
Now go to WordPress Admin → Plugins.
You’ll see your plugin listed.
Activate it.
Congratulations — you just created a WordPress plugin.
Why This File Is So Important
That comment block at the top is how WordPress:
- Identifies your plugin
- Displays it in the admin area
- Tracks versions
Even professional plugins rely on this exact same mechanism.
There’s nothing “basic” about it — it’s foundational.
Step 3: What This Plugin Will Do (On Purpose)
For this tutorial, we are building a front-end utility plugin that:
- Has no admin UI
- Uses actions and filters
- Modifies front-end behavior only
Why?
Because most real plugins don’t start as big systems. They start as useful behavior changes.
This approach also keeps things beginner-friendly and performance-aware.
Step 4: Add an /includes Folder (Future-You Will Thank You)
Inside your plugin folder, create:
includes/
Inside that folder, create:
frontend-hooks.php
Now go back to frontend-utility-plugin.php and load it:
require_once plugin_dir_path( __FILE__ ) . 'includes/frontend-hooks.php';
This separation might feel unnecessary now.
It isn’t.
This single habit is one of the reasons my premium plugins stayed maintainable over time.
Step 5: Add Your First Front-End Behavior
Open frontend-hooks.php and add:
<?php
defined( 'ABSPATH' ) || exit;
/**
* Add a custom class to the body tag
*/
add_filter( 'body_class', function( $classes ) {
$classes[] = 'frontend-utility-plugin-active';
return $classes;
});
Refresh your site and inspect the <body> tag.
You’ll see the new class.
You just:
- Modified front-end behavior
- Without touching the theme
- Using a plugin
This is the core power of WordPress plugins.
Why I Default to Actions and Filters
In my real-world work, actions and filters are my first choice because they:
- Are update-safe
- Respect WordPress core
- Avoid theme lock-in
- Scale cleanly
You’re not changing WordPress — you’re extending it.
That distinction matters.
The Most Important Lesson: Plugins Are Products
Here’s the mindset that changed how I build plugins:
Every plugin is a product — even the small ones.
That means:
- Clean structure
- Thoughtful naming
- Versioning from day one
- Respect for users and performance
This mindset is what separates fragile snippets from reliable tools.
What’s Next in This Mini-Series
In Part 2, we’ll cover:
- Why
functions.phpbecomes dangerous - How to move front-end logic into a plugin
- When code belongs in a plugin vs a theme
That’s where most beginners get stuck — and where things start to click.