Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $tags = wp_get_post_terms($post->ID, 'client_name');
- $args = array (
- 'tax_query' => array (
- 'taxonomy' => 'client_name',
- 'terms' => $tags[0]->term_id
- ),
- 'post_type' => 'project'
- );
- $query = new WP_query($args);
- if ( $query->have_posts() ) : {
- while ( $query->have_posts()) : $query->the_post();
- $postcats = get_the_term_list($post->ID,'project_type','','','');
- if ($postcats) {
- foreach($postcats as $cat) {
- $all_cats_arr[] = $cat -> name; //USING JUST $cat MAKING $all_cats_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
- }
- }
- endwhile;
- }
- endif;
- $cats_arr = array_unique($all_cats_arr); //REMOVES DUPLICATES
- echo '<li>'.print_r($cats_arr, true).'</li>'; //OUTPUT FINAL CATS
- wp_reset_query();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement