I often want to create a set of taxonomy filters to use alongside a query, but using `get_terms()` with the taxonomies attached to the post type returns all of the terms in the taxonomy even if none of the posts inside the query have that term attached.
I often want to creating a set of taxonomy filters to use alongside a query, but using `get_terms()` with the taxonomies attached to the post type returns _all_ of the terms in the taxonomy even if none of the posts inside the query have that term attached. My current workaround looks like this: ```php // Get some posts $posts = Timber::get_posts([ "post_type" => "projects", "category_name" => "featured", "posts_per_page" => "-1" ]); // Make an array to hold the query's active taxonomies $query_taxonomies = []; // Loop through all the posts in the query foreach ($posts as $post) { // Then loop through their terms foreach ($post->terms() as $term) { // Add a key to the array of taxonomies if it doesn't have one if (!array_key_exists($term->taxonomy, $query_taxonomies)) { $query_taxonomies[$term->taxonomy] = []; } // Add the term's ID to the corresponding taxonomy array if it isn't already included if (!in_array($term->id, $query_taxonomies[$term->taxonomy])) { $