jawittdesigns
11/7/2016 - 6:03 PM

List all posts with taxonomy

List all posts with taxonomy

SELECT ID, post_type, terms
FROM( SELECT ID, post_type
,(SELECT group_concat(wp_terms.name separator ', ') 
    FROM wp_terms
    INNER JOIN wp_term_taxonomy on wp_terms.term_id = wp_term_taxonomy.term_id
    INNER JOIN wp_term_relationships wpr on wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
    WHERE taxonomy = 'the_taxonomy'
    AND wp_posts.ID = wpr.object_id
) AS "terms"
FROM wp_posts )
AS x
WHERE terms IS NOT NULL