Filter second dropdown (tax) based on first dropdown (cpt)

If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your “functions.php”: function my_dropdown_categories( $taxonomy, $current_selected = ”, $include = null ) { // Get all terms of the chosen taxonomy $terms = get_terms($taxonomy, array(‘orderby’ => ‘name’)); // our content variable $list_of_terms=”<select … Read more

Add term list as class

If you use return then your loop will not work properly. You can try the code this way: <?php while($portfolio->have_posts()) : $portfolio->the_post(); ?> <?php $term_class=””; $categories = get_the_terms($post->ID, ‘project_type’); foreach($categories as $category){ $term_class .= ‘ ‘ . $category->name; } ?> <div class=”portfolio-tile <?php echo trim($term_class) ;?>”> <?php the_post_thumbnail(‘medium’ ); ?> </div> <?php endwhile; ?> </div> … Read more