Guest User

Untitled

a guest
Dec 14th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. <?php
  2. // Below we search for the Location name
  3. $custom_terms = get_terms('team-locations');
  4. foreach($custom_terms as $custom_term) {
  5. wp_reset_query();
  6. $args = array('post_type' => 'qp_team',
  7. 'tax_query' => array(
  8. array(
  9. 'taxonomy' => 'team-locations',
  10. 'field' => 'slug',
  11. 'terms' => $custom_term->slug,
  12. ),
  13. ),
  14. );
  15.  
  16. $loop = new WP_Query($args);
  17. if($loop->have_posts()) {
  18. echo '<h2>'.$custom_term->name.'</h2>';
  19. }
  20. }
  21. ?>
  22. <?php
  23. // Get the groups and show their related teachers
  24. $custom_terms_group= get_terms('team-group');
  25. foreach($custom_terms_group as $custom_term) {
  26. wp_reset_query();
  27. $args = array('post_type' => 'qp_team',
  28. 'tax_query' => array(
  29. array(
  30. 'taxonomy' => 'team-group',
  31. 'field' => 'slug',
  32. 'terms' => $custom_term->slug,
  33. ),
  34. ),
  35. );
  36.  
  37. $loop = new WP_Query($args);
  38. if($loop->have_posts()) {
  39. echo '<h2>'.$custom_term->name.'</h2>';
  40.  
  41. while($loop->have_posts()) : $loop->the_post();
  42. echo '<a href="'.get_permalink().'">'.get_the_title().'</a><br>';
  43. endwhile;
  44. }
  45. }
  46. ?>
Add Comment
Please, Sign In to add comment