-
-
Save kurtschlatzer/f578d6ad923833ebe14df148dd85fbe7 to your computer and use it in GitHub Desktop.
Select All posts that are missing featured image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# First Attempt, seemed to have worked | |
SELECT DISTINCT(p.ID), p.post_title, p.post_content FROM `wp_posts` p | |
LEFT JOIN wp_posts im ON p.ID = im.post_parent AND im.post_type = "attachment" | |
WHERE p.post_status ='publish' | |
AND p.post_type = "product" | |
AND im.ID IS NULL | |
AND p.post_content NOT REGEXP 'src=".*"' | |
# This works well with woocommerce products. | |
# Fast | |
SELECT * FROM wp_posts WHERE ID NOT IN (select post_id from wp_postmeta WHERE meta_key="_thumbnail_id") AND post_type="product"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment