Created
December 3, 2020 18:35
-
-
Save edvm/5b5cfabf9640fe0519a789d5722ed01f to your computer and use it in GitHub Desktop.
Export all published wordpress posts with hero - featured images:
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
SELECT | |
display_name, | |
p1.*, | |
wm2.meta_value | |
FROM | |
wp_posts p1 | |
LEFT JOIN | |
wp_users ON | |
wordpress.wp_users.ID=p1.post_author | |
LEFT JOIN | |
wp_postmeta wm1 | |
ON ( | |
wm1.post_id = p1.id | |
AND wm1.meta_value IS NOT NULL | |
AND wm1.meta_key = "_thumbnail_id" | |
) | |
LEFT JOIN | |
wp_postmeta wm2 | |
ON ( | |
wm1.meta_value = wm2.post_id | |
AND wm2.meta_key = "_wp_attached_file" | |
AND wm2.meta_value IS NOT NULL | |
) | |
WHERE | |
p1.post_status="publish" | |
AND p1.post_type="post" | |
ORDER BY | |
p1.post_date DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment