How to find WordPress posts with thumbnails using phpMyAdmin

I recently needed to re-do my image thumbnails inside all WordPress posts.

I decided to use phpMyAdmin to run a SQL query to list all posts with thumbnails, then individually update each post from the WordPress admin.

Here’s the SQL query I used in phpMyAdmin:

SELECT *
FROM `wp_posts`
WHERE (
`post_content` REGEXP '([0-9]+x[0-9]+).(gif|jpeg|bmp|jpg|png)'
AND `post_type` = "post"
)

How to find WordPress posts with thumbnails

  1. Log into the cPanel for your website. The address is usually www.website.com/cpanel, and the username and password would have been provided by your host when you first joined.
  2. Under ‘Databases’ click on the icon for ‘phpMyAdmin’ – this is the tool they provide to manage the databases linked to your hosting service.
  3. WordPress-phpMyAdmin1
  4. Using the left hand manu, click on the ‘wp_posts’ table
  5. WordPress-phpMyAdmin2
  6. Click on the ‘Inline’ link and enter the following query
  7. SELECT *
    FROM `wp_posts`
    WHERE (
    `post_content` REGEXP '([0-9]+x[0-9]+).(gif|jpeg|bmp|jpg|png)'
    AND `post_type` = "post"
    )
  8. WordPress-phpMyAdmin3
  9. Click ‘Go’ to run the query
  10. The results returned will be each post that has a thumbnail in the content.
  11. WordPress-phpMyAdmin4
  12. For each result, take the ID number and enter into the WordPress admin edit URL.
  13. For example, https://www.website.com/wp-admin/post.php?post=1602&action=edit
  14. Now you can edit the post, updating or removing each thumbnail.