How do I sort posts by custom taxonomy?

If I understand your question correctly, I think I may have your answer in this blog post: https://evowebdev.com/2017/05/using-a-dropdown-menu-to-filter-a-custom-post-type-with-custom-taxonomy/ This solution specifically uses select form element auto-populated with taxonomy terms to sort CPT posts (ie, rather than presorting posts with pre_get_posts, it lets site visitors sort by the taxonomy term[s] they select). If it’s really important … Read more

Query all posts in a given taxonomy

Have you tried simply omitting the ‘terms’ key from the ‘tax_query’ array? $query03 = array( ‘numberposts’ => 5, ‘post_type’ => array( ‘video’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product’, ‘field’ => ‘slug’ ) ) ); Alternately, I wouldn’t really worry about the weight of the query. The resulting query will be what it will … Read more

How to output content based on same custom taxonomy?

we meet here again 🙂 Try using this: $term_list = wp_get_post_terms( $post->ID, ‘persons’, array( ‘fields’ => ‘ids’ ) ); and ‘tax_query’ => array( array( ‘taxonomy’ => ‘persons’, ‘field’ => ‘id’, ‘terms’ => $term_list ) ), AFAIK, the tax_query accepts field by id or slug only (see here. And the wp_get_post_terms accepts only names (not slug), … Read more