• Hi, I would like to grab the featured images from the categories and not from all posts.
    for now I got this, how can I filter this response to get only a specific category, let’s say category id= 5 ?
    thanks for any help

    SELECT
    	p1.*,
    	wm2.meta_value
    FROM
    	wp_posts p1
    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
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘mysql featured image category’ is closed to new replies.