Last active
August 29, 2015 14:21
-
-
Save mmcachran/052a24dd3d1465e58f7a to your computer and use it in GitHub Desktop.
Get posts by taxonomy
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 | |
post_title, | |
post_type, | |
wp_terms.* | |
FROM wp_posts | |
LEFT JOIN wp_postmeta | |
ON(wp_posts.id = wp_postmeta.post_id) | |
LEFT JOIN wp_term_relationships | |
ON(wp_posts.id = wp_term_relationships.object_id) | |
INNER JOIN wp_term_taxonomy | |
ON(wp_term_relationships.term_taxonomy_id = | |
wp_term_taxonomy.term_taxonomy_id) | |
INNER JOIN wp_terms | |
ON(wp_terms.term_id = wp_term_taxonomy.term_id) | |
WHERE | |
wp_posts.post_status = 'publish' | |
AND wp_posts.post_parent = 0 | |
AND wp_term_taxonomy.taxonomy = 'category' | |
AND wp_terms.name LIKE '%App%' | |
ORDER BY | |
wp_terms.name ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment