WordPress: Find images without alt text

WordPress always adds an alt attribute to images added via the Media Library so finding images without alternative text is easy!

What we need to do is:

  1. Get posts of all Post Types
  2. Only get Published, Privately Published & Draft posts
  3. Look for the presence of an img tag with an empty value for alt


SELECT * FROM `wp_posts`
WHERE post_status IN ('publish', 'draft', 'private')
AND post_content LIKE '%<img%alt=""%'

Leave a Reply

Your email address will not be published.