How I Automated SEO for WordPress Media Using OpenAI

Dagoberto Medina
3 min readAug 29, 2024

--

Sometimes, you just need to make life easier. A friend of mine was dealing with a lot of images on their WordPress site, and manually adding SEO details to each one was becoming a real headache. That’s when I thought, “Why not automate this?” And so, I ended up building a WordPress plugin that uses OpenAI to handle the heavy lifting.

Let me take you through how it all came together, from the initial idea to the finished plugin, which I’m now sharing on GitHub as part of my ongoing projects with Tropical Devs.

The Problem: Too Many Images, Not Enough Time

So here’s the deal — my friend’s WordPress site was growing, and so was the media library. Adding SEO-friendly titles, descriptions, and alt text for each image manually? Not fun. They needed something that could streamline this process and make sure every image was optimized without spending hours on it.

Getting Started with the Right Tools

Before diving into coding, I wanted to make sure I had a solid foundation. That’s where WPPB came in handy. It’s a boilerplate generator for WordPress plugins, and it saved me a ton of time by giving me a clean structure to start with.

Using OpenAI’s API to Do the Heavy Lifting

The real magic of the plugin comes from OpenAI’s API. This API is incredibly powerful for generating human-like text, so it was a perfect fit for creating SEO-friendly content. By feeding it some details about the image, the API can spit out optimized titles, descriptions, and alt text.

One cool feature I added is the option to choose between different OpenAI models: GPT-4o and GPT-4o-mini. This gives users the flexibility to prioritize either precision or cost, depending on what they need.

Generate your key on open ai dashboard
Use your new key into the plugin configuration options

Building the Plugin: Step by Step

Once I had the boilerplate and API integration ready, it was time to build. Here’s how it all came together:

  1. Automatic SEO Generation: The plugin automates the creation of titles, descriptions, and alt text, so you don’t have to.
  2. Batch Processing: Need to update multiple images? No problem. The plugin lets you select multiple items in the media library and generate SEO for all of them at once.
  3. Customizable Options: Choose the OpenAI model that fits your needs, whether you’re looking for the best accuracy or the most cost-effective option.
Bulk Media SEO with OpenAI

Sharing the Plugin

After seeing how well the plugin worked, I realized it could help a lot more people. So, I decided to make it public on GitHub. This is also the first project under Tropical Devs, a new company I’m launching with some colleagues. We’re all about helping organizations with cloud solutions, development, QA, project management, frontend development, and more.

You can check out the plugin here on GitHub.

Wrapping Up

What started as a small project to help a friend has turned into something much bigger. Not only did I get to create something useful, but it also helped kickstart Tropical Devs. If you’re dealing with a growing media library in WordPress and need some SEO automation, give the plugin a try. And if you find it helpful, don’t forget to star the repo and leave your feedback!

Thanks for reading! Feel free to drop any comments or questions below.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Dagoberto Medina
Dagoberto Medina

Written by Dagoberto Medina

Full Stack & DevOps. Cybersecurity enthusiast and continuous improvement.

No responses yet

Write a response