For Advanced Forum:
So, basically I have a custom post type that has several taxonomies associated with it.
Comic (Post Type)
– Chapter (taxonomy)
– Characters (taxonomy)
What i’m trying to get is get the characters (terms) that are inside of a specific chapter (taxonomy ID)
I’ve been following this thread from 3 years ago http://wordpress.org/support/topic/get-tags-specific-to-category?replies=38 and it doesn’t seem to want to return anything for me, maybe if someone could tell me where I went wrong?
$chapter = 3; // ID # of chapters taxonomy $sql_string3 = "SELECT DISTINCT terms2.name as tag FROM wp_posts as p1 LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id, wp_posts as p2 LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id WHERE t1.taxonomy = 'chapters' AND p1.post_status = 'publish' AND terms1.term_id = ".$chapter." AND t2.taxonomy = 'characters' AND p2.post_status = 'publish' AND p1.ID = p2.ID";
- The topic ‘Get terms based on posts that are in a custom taxonomy of a custom post type.’ is closed to new replies.