-
-
Save hoangitk/94b47afa52e63ce2929295bfe89a47e2 to your computer and use it in GitHub Desktop.
SQL Query to get Latest Wordpress Post with Featured Image.
This file contains hidden or 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 DISTINCT wp_posts.id, wp_posts.post_title, wp_posts.post_content, wp_posts.post_type, featured_image.guid as post_image, wp_posts.post_modified, wp_users.display_name | |
from wp_posts | |
inner join wp_postmeta on wp_posts.id = wp_postmeta.post_id and wp_postmeta.meta_key = '_thumbnail_id' | |
inner join wp_posts as featured_image on featured_image.id = wp_postmeta.meta_value | |
inner join wp_users on wp_users.id = wp_posts.post_author | |
where wp_posts.post_status = 'publish' | |
order by wp_posts.ID desc | |
limit 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment