I am largely writing this as a note to self, but perhaps it also helps others since I spent a few hours getting this to work, while it can be done in 10 minutes.
Step 1. Go to your WordPress user profile in wp-admin and generate an API key for your user. The user should have the capability to post, of course.
Step 2. Encode the string “username:apikey” in base64. The API key will have some spaces, but it does not matter, paste it all in there, including the spaces.
Step 3. Create a GPT, under actions click on Create New Action.
Step 4. Under Authentication select API Key -> Basic, and just paste in the base64 encoded string.
Step 5. Now, the main section is the schema. This is where you describe how the WordPress API works. It is in OpenAPI format. Attention, it looks a lot like OpenAI, but there’s a P in there. It’s a different word.
Step 6. OpenAI has a custom GPT called ActionsGPT, that will basically do all of this work for you. You just tell it that you need actions to post drafts, or to read media library items or whatever, and it writes the OpenAPI schema for you, because it already knows how WordPress works, since it’s so widely used.
Step 7. In the OpenAPI schema that ActionsGPT will generate, you just need to fill in the URL of your website that will look something like https://example.com/wp-json/wp/v2
Step 8. I wasted an hour or so because I had http instead of https, so pay attention to this as well. It needs to be https, at least for the 2 websites that I have tested. Maybe others need to be http. But the point is that it matters, it is relevant. Another instance where a single letter makes a big difference.
That’s pretty much it.