Showing posts from June, 2016

Get wordpress posts and featured Image via direct sql query

Use below MySql query to get wordpress posts with featured image

SELECT p1.*, wm2.meta_value FROM wp_posts p1 LEFTJOIN wp_postmeta wm1 ON( wm1.post_id = AND wm1.meta_value ISNOTNULLAND wm1.meta_key ="_thumbnail_id")LEFTJOIN wp_postmeta wm2 ON( wm1.meta_value = wm2.post_id AND wm2.meta_key ="_wp_attached_file"AND wm2.meta_value ISNOTNULL)WHERE p1.post_status="publish"AND p1.post_type="post"ORDERBY p1.post_date DESC