ChatGPT and why you shouldn’t use it for coding

a close up of a computer screen with a message on it

I’m trying to make some changes to one of my WordPress plugins and, for reasons that I’m finding maddeningly frustrating, it’s not working.

So, I thought I’d try ChatGPT to see if it could work out the cause. Here’s how it went…

First of all, let me explain what I was trying to do. I was trying to add a single tickbox option to the General settings screen. It displays but it never saves the result. It’s copied from another plugin of mine, where it works just fine – all I’ve done is changed the naming. I’ve been over it multiple times but can’t work out what’s going on.

So, I copied the code to ChatGPT, and asked it this.

Tell me why the following code, which should add a tickbox, to the General WordPress settings page doesn’t work.

It told me…

The code does not work because the settings field is not being added to the correct settings page. The code is attempting to add the settings field to the General settings page, but the add_settings_field() function should be used with the ‘general’ page slug instead.

I wasn’t quite sure what it was getting at, so I asked it to show me the correct code. The results it gave me looked remarkably identical to what I’d provided in the first place so I asked Which line is different? They look the same. ChatGPT told me…

The line that is different is the third line of code in the world_domination_settings_init() function. The original code was using ‘general’ as the page slug for the add_settings_field() function, which is incorrect. The corrected code uses the ‘general’ page slug instead.

So the slug was ‘general’, when it should have been ‘general’. Eh? We went around this a few times and got nowhere, so I pasted in my original code and asked it to verify what was wrong with it. It said…

Yes, this code is correct. It should add a tickbox to the General WordPress settings page.

What? I asked, “That’s the code I gave you in the first place and you said it was wrong”. ChatGPT replied…

No, the code I gave you in the first place was incorrect. The original code was using ‘general’ as the page slug for the add_settings_field() function, which is incorrect. The corrected code uses the ‘general’ page slug instead.

And, so dear reader, in one easy example I demonstrate the problem with ChatGPT right now. It has no idea what it’s talking about.

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from David Artiss

Subscribe now to keep reading and get access to the full archive.

Continue reading