ChatGPT is an amazing tool that can enable you to do even more with WordPress. It will also help you learn WordPress much deeper and much faster.
I asked ChatGPT to write a WordPress plugin for me from scratch, as well as some code snippets and website customizations.
00:00 How To Use ChatGPT For WordPress Customizations
00:37 Write Easy Code
03:09 Write Harder Code
07:53 Write A Plugin
#chatgpt #wordpress
If you want to speed up your WordPress website:
If you want to make a WordPress online store:
If you want to make a WordPress blog:
I’ve asked chatgpt to write me a new WordPress plugin completely from scratch And as you can see it’s doing it right Now this new AI can help you do things In WordPress that you normally can’t do If you don’t know how to code it can Generate some code to customize this Text on your woocommerce checkout page It can add a new product label to new Products it can even code a whole plugin That adds a custom fee to the shopping Cart and in this video I will show you How I’ve used chatgpt to do all of this And more this tool will greatly improve The things that you can do with WordPress and it will enable you to Learn WordPress much faster and much Deeper so I have my woocommerce store And let’s find something that we want to Edit this is my checkout page and let’s Say that we want to edit this billing Details text or perhaps this first name Label this page is built using Elementor But this is only a shortcode so we can’t Edit any of these fields right from here The only way to do it is by using a Piece of custom code so let’s try to get Chat GPT to write the code for us just Go to openai.com then scroll down and go To chat GPT again scroll down and try Chat GPT you can log in using your Google account and I will do that right Now so now we are logged in and we can Start talking to the AI so for example I
Can ask you to write me some code to Change the first name and last name Labels on the woocommerce checkout page Let’s see what it comes up with so it’s Starting to write this code that’s going To overwrite the name and last name Fields and funnily enough it overwrote Them with as it appears on your IDE but It’s telling us some useful stuff as Well like we can add this to our Functions.php file to make it work so Let’s try to do that we can copy this Code and then go back to our WordPress Dashboard and from appearance we can go To the steam file editor from here we Can open up functions.php just like it Instructed us and we can scroll all the Way down and we can paste that code now I’m simply gonna write your first name And your last name Without the as it appears on your ID Part that the chatbot added then we can Update our file and let’s go to our Checkout page and refresh it and now we Get our new labels in here your last Name and your first name so that’s great But next let’s say that we also want to Change this country label so let me go Back to chat GPT and I will ask it to Also change the country label And it gives us the same code but now we Have this country field so we can copy It and again we can paste it inside WordPress and I will simply name mine
Your country again update the file go to The checkout page and let’s make sure That it works and it does we now have The your country label so chatgpt was Able to create these code Snippets for US based on what we told it and it Remembers what we spoke about before Because we can add to it and it will Update the code accordingly it’s not Perfect but it certainly has the Potential to help you learn some of These things much faster next up let’s Click this new thread and we will try to Make it do something a bit harder I will Tell it to write me a WordPress code That adds a label to products that have Been published in the last 24 hours All right so this is pretty impressive It wrote a code that’s gonna add the Label to our product titles on the shop Page and it tells us that it assume that We want to add this label to the product Cards on the shop page it’s using this Filter right here and everything looks Good to me I’m pretty sure that this Label works it even gave us some CSS Code to style it and have it look better But I don’t want my labels to show on The shop page I want them on the single Product page so I’m going to say place The label on the single product page Just below the product Title let’s see if it adjusts it Alright so this looks pretty good let’s
Copy the code and let me show you what I Mean back on my store I’m going to want To go to a product page so I’ll just Open up this one and I told it to add a Label right below this title so let’s go To our functions.php file and let’s copy That new code update the file and There’s actually something that I want To edit here first because it’s gonna Show this on products that have been Published in the past 24 hours so if the Publishing date is less than one day ago It’s going to show our label but I don’t Have any products that have been Published in the last 24 hours so Instead of one day I’m gonna make this 90 days and then I’m gonna update the File now let’s go to my product page and Refresh it and we get our label and it’s Right here it’s not quite below the Product title like we wanted so maybe Let’s go back to chatgpt and let’s try To tell it to move it further down so Move this label further down under the Title So this is really really cool because It’s telling us exactly what it changed In this code the function is hooked into The product summary action with a Priority of 20. so it’s describing the Priority that is stated in here and it Tells you exactly what this does by Default the title is displayed with the Priority of 10. so if we change it to 20
It’s gonna display further down so with This information we can go back to WordPress and instead of one we will Make our priority 20 just like the Chatbot recommended then update the file And let’s refresh the page again to see What that did so the priority of 20 Moved it all the way down here but let’s Go back and we can try a priority of 10 Then update the file and let’s see what That did it’s still too far down so Let’s play around with it let’s make it 5. Again refresh the page and now it’s Right above our title I think that’s Good enough and the chatbot was smart Enough to let us know what we need to Change to get the desired result next Let’s see if it can help us add some Styling to it so I will say make the Text have a green background with a Radius of 4 pixels and I also want white Text and some space around it And the answer that it gave us is not Exactly what I expected but it’s still Helpful enough it’s telling us to insert This CSS code for the product label Class let’s see if we can make it right This CSS is inline so I will say can you Write this as inline CSS inside the Original code And this is not what we wanted so maybe We can click try again and let’s see if It comes up with something better
Alright so after trying again a couple Of times this is exactly what we wanted It’s even telling us that this is not The best solution but it’s gonna be Workable and this is exactly what I Wanted because I just want something Fast so I’m going to copy this new part Of the code and I’m going to replace my Old code inside WordPress now we have Our styling here and we can update the File and let’s see how it looks we can Refresh it and we have our green Background with the 4 pixel border Radius just like we asked it we could Make some further adjustments if we want Like we could give it some more padding On both sides like this and then of Course we can make it look exactly how We want by adjusting all of this with Chat GPT provided a great start alright So we were able to get it to add labels To our single product page next let’s Have it make something even harder I Will again go to a new thread and this Time let’s see if it can write a full Plugin for us so on my store I offer two Payment methods cash on delivery and Stripe but if the customer chooses cash On delivery I want to add a five dollar Fee to their total so let’s get chat GPT To write that plugin for us and I think The best way to do it would be to have It write the code for our plugin first So I’ll say write me some WordPress code
That adds a five dollar shipping fee to The Cod payment option Alright so we generated this code first We’re gonna get the customers chosen Payment method and then if that payment Method is cod then we add a five dollar Fee to their card so we can copy this Code and let’s test it inside our Functions.php file update the file then Refresh our checkout page and because we Have cache and delivery selected now we Get this Cod shipping fee of five Dollars added perfect but now let’s say That we only want this fee to be added If the address of the customer is Outside California so add the fee only If the shipping address is outside California so it generates an updated Version that applies the fee only if the Address is outside California It gets the customer’s shipping State And if it’s not California then it adds Our surcharge so let’s copy this new Code and let’s test it out inside Functions.php update the file then go Back to the checkout and refresh it so Now our state is California and we don’t Have the fee added but let’s change the State and now our Cod shipping fee is Added let’s go back to California and Our fee is removed perfect so now let’s See if we can turn this into a plugin I’ll simply ask can you turn this into a Plugin
Foreign Adjusted this code in a way that we can Use to create a small plugin and we can Simply copy this code and let’s make a New plugin real quick we can just make a New folder and I’ll call it Cod fee then Inside it I will make a new text Document and I will call it Codv.php make sure the extension is that PHP then edit the file and we can paste Our code inside here if you want to Change the name of your Plugin or the Description you can do it up here also If you want to add your name as the Author you can do it like this or of Course you can ask chadgpt to do it for You so let’s save this file and now I Will make it into a zip or Hive just add To Archive and select zip now we have Our new plugin here and we can upload it To our website so let’s go to it and First I will want to remove my code from The functions.php file because it’s no Longer needed then go to plugins and add New and let’s upload our new plugin I Can simply drag it inside here and then Install now click activate plugin and Our Cod shipping fee plugin is now Activated we can also go to the plugin File editor and if you ever need to edit Your plugin just select it in here so This is an easy way to make a super Simple plugin by using chat GPT next I Want to use chatgpt to quickly learn how
To code more complex things for WordPress like making a custom Elementor Widget from scratch or perhaps making a Gutenberg block I’ll make videos about It so be sure to subscribe for more Content just like this I will see you in The next one