WP-CLI Alt Text Generator for WordPressWordPress logo

Generate alt text for your WordPress images from the terminal

AltTextGeneratorAI WordPress plugin adds an alt-text command to WP-CLI. Use it to generate alt text for your whole Media Library in one command after a migration, as a scheduled job, or as part of a deploy script.

Before you start:

  • AltTextGeneratorAI WordPress plugin is installed and active
  • Your API key and website domain are saved in AltTextGenerator > Settings. The command uses the same saved settings.

Commands

wp alt-text status

Shows your API status, remaining credits, website domain, language and how many images are missing alt text.

wp alt-text generate

Generates alt text for every image in your Media Library that has none.

Options for wp alt-text generate

--short

Also regenerate images whose alt text is shorter than 20 characters.

--all

Regenerate every image in the library, even if it already has alt text.

--ids=<ids>

Only process these attachment IDs (comma-separated).

--force

Used with --ids. Regenerates even if the image already has alt text.

--limit=<number>

Process at most this many images in one run.

--dry-run

Lists the images that would be processed without calling the API or using credits.

Each image uses one credit. Run wp alt-text status first to check your balance, and add --dry-run to preview large jobs.

Examples

# Check API status, credits, and how many images are missing alt text
wp alt-text status

# Generate alt text for every image that's missing it
wp alt-text generate

# Also regenerate images whose alt text is too short
wp alt-text generate --short

# Regenerate every image in the library
wp alt-text generate --all

# Regenerate specific attachments, even if they already have alt text
wp alt-text generate --ids=12,34,56 --force

# Preview what would be processed, without using any credits
wp alt-text generate --limit=20 --dry-run
1

How to connect and run WP-CLI

WP-CLI runs on the server that hosts your site, so you connect to that server over SSH. FTP will not work, because it only transfers files. Many hosts, including Hostinger, SiteGround, Kinsta, Cloudways and WP Engine, offer SSH and have WP-CLI installed already.

  1. Enable SSH in your hosting panel. On Hostinger, go to Websites > your site > Advanced > SSH Access and click Enable. On other hosts, look for "SSH Access" or "Terminal".
  2. Set an SSH password (click Change next to Password) and note the IP address, port and username shown there.
  3. Open a terminal. On Mac use Terminal. On Windows use PowerShell, Windows Terminal or PuTTY.
  4. Connect with the command your host shows, in this form:
ssh -p PORT USERNAME@IP_ADDRESS

# Example
ssh -p 65002 u123456789@203.0.113.10

Type yes if asked to trust the server, then enter your SSH password. Nothing appears while you type it, which is normal.

  1. Go to your WordPress folder, the one that contains wp-config.php. On Hostinger it looks like this:
cd domains/yourdomain.com/public_html
ls
  1. Run the commands from the lists above, starting with wp alt-text status.
  2. Disconnect by typing exit.

If your host does not have WP-CLI, install it from wp-cli.org. If you use LocalWP or DDEV for local development, use "Open site shell" or ddev wp instead of SSH.

2

Test the command

  1. Confirm WP-CLI is available: wp --info
  2. Confirm the plugin is active: wp plugin list --status=active should show alt-text-generator-ai
  3. Run wp alt-text status. It should show "API Status: Verified" and your credits. If it says "Not Verified", save your API key and domain in AltTextGenerator > Settings first.
  4. Run wp alt-text generate --limit=5 --dry-run to see which images would be processed, without using credits.
  5. Run wp alt-text generate --limit=1 to generate alt text for one real image. Then check it in the Media Library: the Alternative Text field should be filled and your credit count should drop by one.
  6. Once that works, run wp alt-text generate (add --short or --all if you want those too) to process the rest of your library.

WP-CLI Alt Text FAQs

Does WP-CLI generation use credits?

Yes. Each image uses one credit, the same as generating from the WordPress dashboard. Using --dry-run lists the images without calling the API, so it costs nothing.

Can I run it on a schedule?

Yes. Because it is a regular command, you can run it from a cron job or a deploy script, for example to cover new uploads each night or to process a library after a migration.

What if my host does not offer SSH?

Use the Bulk Alt Text page inside WordPress instead. It does the same job from your browser, with tabs for images with empty alt text, short alt text and all images.

Which images does it process?

Supported formats are JPEG, JPG, PNG, SVG, GIF, WEBP and AVIF.

🚀

Ready to Get Started?

Install the plugin and run your first command. Get 2 free credits on sign up!