I’ll show you how to create a WordPress plugin from scratch using ChatGPT & OpenAI’s GPT-4. Get ready to make money with your plugin created.
You don’t need to know PHP, JavaScript, or any programming language to create this plugin. You don’t need to be a programmer. Just clearly explain to GPT-4 what you want to achieve. Let’s get started.
Building a New WordPress Plugin Using ChatGPT / GPT-4
First, let’s decide on our goal:
We’ll create a plugin for WordPress that improves post titles using OpenAI’s GPT models. There will be a settings page where users can enter their API keys, and after that, they can use the plugin.
What do we need?
Just access to ChatGPT (GPT-4) is enough.
Step 1: Finding a name for the plugin
First, we need to find a name and description for our plugin. Let’s start with that.
We are going to use ChatGPT for that as well.
Prompt
I want to develop a plugin for WordPress using OpenAI’s API services. Users who install this plugin will be able to improve the titles of the content they produce on their WordPress sites. Can you suggest at least 3 names for my plugin? The names should be in English, not too long, and should be simple yet understandable.
Step 2: Generating a template
After finalizing the name and description, we should visit https://wppb.me to generate a template for our WordPress plugin.
On this website, we fill in the form with details like our plugin’s name and description, then click on ‘Build Plugin’ button.
It will provide you with a zip file. We can use this .zip file as our base template for the plugin.
After successful installation, it will appear in the plugin list.
Since we’ve only created a template, the plugin doesn’t have any functionality yet.
Step 3: Returning to ChatGPT to analyze the template
Now, let’s return to ChatGPT. We’ll upload this zip file and ask it to analyze the project.
Prompt
I’ve created a simple template for my plugin using a boilerplate. It’s contained within the attached zip file. I’d like you to analyze this project and extract information like the folder structure and where specific code is located.
You might be wondering how to upload a zip file to ChatGPT.
It’s quite straightforward, but you need access to the GPT-4 model, which means you should be a ChatGPT Plus member.
On the main screen, you need to select the GPT-4 and then choose the Advanced Data Analysis model from the pop-up window.
After that, you can upload the zip file using the plus icon located to the left of the text box where you send messages.
Step 4: Adding the first functionality into the plugin
After analyzing the project, we can start adding functionality.
First, we should create a link in the left menu for our plugin. There should be a welcome message, a brief description, and a form where users can save their OpenAI API key.
Prompt
Now, we need to add a link to the left-side menu in the WordPress admin dashboard for our plugin. Let’s name the menu ‘AI Headliner’. When clicked, it should display a welcome message, a brief description, and below them, an input field where users can enter their API key. When the user clicks the save button, under which name should we store this key in the wp_options table?
ChatGPT has written all the codes. All we have to do is paste the provided codes into the appropriate places.
To add the codes, you can unzip the previously downloaded zip file and open it in an editor like VSCode.
As you can see, we now have our link in the left menu, and when clicked, it opens a page where the API key can be entered.
When we enter ‘my_api_key’ for testing purposes, we see that it’s saved in the database.
Everything is great so far.
Step 5: Adding additional functionalities
Now, let’s add another option.
When the user activates this feature, let’s add a link under each post on the page where the articles are located that says ‘Improve this title’.
Prompt
Great. Now, we’ll add another option to this settings page, and we’ll name it ‘Enable’. We’ll place a checkbox, and by default, it will be unchecked. If the user checks it, we’ll save the value as 1 or 0 in the wp_options table. Just like with the API key, we should retrieve this value from the database every time the page loads.
ChatGPT generated the necessary codes for this process and told us where to paste them. We also see that the settings are saved as 1 or 0 in the database when we save them. Great.
Now, if this option is selected, we want the relevant link to appear below the articles.
Prompt
Great. Now, if this checkbox is enabled, on the ‘All Posts’ page, when we hover over the posts with the mouse, we will add a new link, similar to the ‘Edit’ and ‘Quick Edit’ links. We will name it ‘Improve This Title’. For now, let’s just add this link; we’ll write its functionality later.
After adding the code and going to the ‘All Posts’ page, when we hover over any article, we indeed see the ‘Improve this title’ link appearing.
Step 6: Calling OpenAI’s GPT API
So far, everything is great. Now, it’s time to define what should happen when this link is clicked.
Upon clicking, we’ll send a request to OpenAI to improve the title, and then we’ll update our article’s title with the received response.
Prompt
Okay, that sounds good. When the link is clicked, we need to make an API call to the OpenAI GPT-3.5 model to improve the selected title. On clicking the link, send a request to the OpenAI GPT-3.5 model and update the article’s title with the returned result. We need to send a prompt in the format “Improve this title: …” to the Content parameter. Of course, we should insert the selected title into this prompt. Then, we need to take the returned result and use it to update the title.
ChatGPT has generated the necessary codes; all you need to do is copy and paste them into the related fields.
Step 7: Testing the plugin
And now our project is complete. It’s time for testing!
We hover over any article and click on the ‘Improve this title’ link. After waiting a bit, we receive a success message and see that the title has been updated!
If you encounter any unexpected results or errors during testing, you can also ask ChatGPT for assistance.
Step 8: Beautifying the plugin
If you wish, you can enhance the design of the plugin. For this process, we will seek assistance from ChatGPT and utilize one of ChatGPT’s latest features: the image input capability.
For this process, take a screenshot of our plugin. Upload this image to ChatGPT and inform it that this is the settings page of our plugin. Then, request the necessary codes to improve the design.
ChatGPT will provide you with the CSS codes. Incorporate them into the appropriate place in your plugin and test the plugin again. You can repeat this process until you achieve the desired result.
Congratulations, you’ve successfully created a WordPress plugin using OpenAI’s artificial intelligence technology without needing any programming knowledge.