Not A Subscriber?

Join my newsletter to receive insights, findings and tips that I've been discovering. All from creating a set of digital products and building an online business.

How To Start Coding A WordPress Plugin

So, you’ve come up with an idea for a WordPress Plugin.

You’ve even figured out which service to use to help you host the plugin. This will allow people to download, install and receive updates to your plugin.

Now it’s time for the bulk of the work.

The coding of the plugin.

But how do you do that? Is there a structure? A way to build your plugin, that is not only easy to get up and running with. But allows you to maintain and develop over the coming months?

Here’s what I did to get moving, coding the WordPress plugin idea I’d come up with.

Sorting Out The Structure

In my previous article about building a WordPress plugin.

I chat about using AI. More specifically a tool called TypingMind. To use things like GPT-4 to remove any blockers that I have.

Again, I turned to AI to try and get moving as fast as possible.

I used TypingMind’s “Pro Coder” character. And asked it questions to help me define the structure that I would need to get a WordPress plugin to work.

Here’s the prompt I used.

“I am building a WordPress plugin using PHP and JavaScript. The idea behind the plugin is to have a popup/widget across the entire front-facing part of the website. There is to be an admin area to for users to manage the widget. Data will be written to data from the admin area and from the front-facing widget. I want you to come up with the folder and file structure as a starting point to help me get up and running with the plugin. You can ask as many questions as you need before getting started”

Within seconds, the “Pro Coder” character had done all the thinking for me.

Here’s how it suggested I structure the plugin.

The structure for my WordPress Plugin


I spent a bit of time creating the folder and file structure for the plugin.

Making sure I rename the files and comments to have the name of my plugin SuperSub in all the right places.

Coding “Version 0” of A WordPress Plugin

Now that I had all the files and folders created and ready to go.

I decided to keep chatting to the “Pro Coder” AI character. To see if it could help me get the initial code written. To get “Version 0” of the code ready to rock.

What I did was start working from the root of the folder. And started asking the “Pro Coder” to write the code like this

“Great can you give me the content of your-plugin-name.php”

Here’s the output again

Using AI to write code for your WordPress Plugin

I’d copy and paste the code from TypingMind’s response. I spent a minute or two changing the code that said ‘your-plugin’ or ‘your_plugin_name’ to reflect the name of my WordPress plugin.

I continued doing this until all the files and the initial version of the code had been completed.

Filling In Knowledge Gaps

The good thing, and the bad thing with using AI to write code for you. You don’t need to know the ins and outs of the code. To understand what is going on.

If you don’t know something.

Or wonder how to structure a code file.

Again I asked the “Pro Coder”

For example. I wasn’t sure where to add the code that it had given me in one of the classes. So I asked:

“Where should this code be implemented new Your_Plugin_Name_Public($this->get_plugin_slug(), $this->get_version());”

Here’s the reply.

How to use AI to help code your WordPress Plugin
Code used for my WordPress plugin SuperSub

It was a case of rinse and repeat. Until I had coded all the files in the WordPress Plugin.

It did take a bit of time. And a lot of questions to GPT-4. To get everything coded and to start to pad out when I wanted for my MVP.

But I was at a point to do some initial testing.

Initial Testing

Now that I’d got all the code written.

I turned to the WordPress site that I had running on my local PC. Here’s how I set up my development environment if you’re struggling.

To make sure I could install and activate the plugin.

I did have a few issues where an error occurred when trying to activate the plugin.

Using the “Pro Coder” and my own knowledge. I kept working through the issues until I was able to activate the plugin, without any errors.

To get to this point took no time at all. And I wasn’t drained, mentally from all the effort.

So. Could I get “Version 1” of the plugin code written? Could I get something to work on the front end of my development website?

“Version 1”: Coding The MVP

Now that I was in a good place.

That I finished defining the structure of the plugin.

That it worked and I could activate it.

At this point, I stopped working on the plugin for that day. Now that I had “version 0” or the plugin coded. I wanted to try using another AI tool to help me write the code for the MVP.

I’m going to go into this in an upcoming blog post.

As a heads up. I planned on coding the WordPress Plugin using Github Copolit to write as much of the code as possible.

Conclusion: Coding A WordPress Plugin

WordPress has its way of doing things.

That it has a certain way that it wants you to structure a plugin.

But it’s not that easy to get your head around.

Even if you have written a WordPress Plugin from scratch before. There are parts of the plugin that get coded once and then you don’t revisit them. Things that you don’t do that often and completely forget how to do.

Getting this task out of the way so you can focus on coding your MVP is critical.

You want to get it done and done right.

That was the next challenge I faced getting the plugin out to the world.

I used AI to help me get over the blocker as fast as possible. To not use much mental energy and time.

Then, I could get on with the fun part of coding the MVP for my WordPress Plugin, aptly named SuperSub

Wait, want more tips & tricks? Yes, please!

Who Is Phil Hughes

I am a coder, content creator & software consultant for start-ups and FTSE 100 companies. I am obsessed with productivity, self-improvement, and building a lifestyle business.
You can work with me to transform your business! Setup a recurring revenue model designed for growth.

When You’re Ready, Here’s How I Can Help You:

10x your productivity with this one simple hack
10X Your Productivity
Discover this simple, yet effective technique. which helps you be ultra-productive and get shit done!
Notion Habit Tracker
Habit Tracker
A personal tracking system that helps you create better habits.
GTD Framework Template using Notion
GTD Notion Template
A timeless framework that helps you get clear, organized, get more done and free up your time.
Online Business Systemization
Online Business Systemization

Learn how to systemise and automate your online business. Free up your time so you can focus your energy on growing your business.

Productivity Bootcamp Course
Productivity Bootcamp
Productivity Bootcamp is a 4 part course, that helps you to get more done. Spend less time on the mundane. And more time doing what you love.

Press S to subscribe

Tap to subscribe

Join my email list for insights, tips and more