Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <?php //for a given post type, return all
  2. $post_type = 'our-team';
  3. $tax = 'team-categories';
  4. $tax_terms = get_terms($tax);
  5. if ($tax_terms) {
  6. foreach ($tax_terms as $tax_term) {
  7. $args=array(
  8. 'post_type' => $post_type,
  9. "$tax" => $tax_term->slug,
  10. 'post_status' => 'publish',
  11. 'posts_per_page' => -1,
  12.  
  13.  
  14. );
  15.  
  16. $my_query = null;
  17. $my_query = new WP_Query($args);
  18. if( $my_query->have_posts() ) {
  19.  
  20. echo '<h2 style="clear:both;">'.$tax_term->name.'</h2>';
  21. while ($my_query->have_posts()) : $my_query->the_post();
  22. //set vars for custom fields
  23. $team_location = get_field('team_location');
  24. $team_position = get_field('team_position');
  25. $team_email = get_field('team_email');
  26. $team_name = get_the_title();
  27. $team_link = get_permalink();
  28.  
  29. //get only first name. usage: echo $first_name[0];
  30. $team_first_name = $team_name;
  31. $first_name = explode(' ', trim($team_first_name));
  32. ?>
  33. <div class="team_member">
  34. <?php if ( has_post_thumbnail()) { ?>
  35. <a class="thickbox" href="<?php echo $team_link; ?>"><?php the_post_thumbnail('medium'); ?></a>
  36. <?php } else { ?>
  37. <img src="<? bloginfo('template_directory' );?>/library/images/no_pic.jpg" alt="no image provide" />
  38. <?php } ?>
  39.  
  40. <div class="team_member_info">
  41. <h2><?php the_title();?></h2>
  42. <p><a class="thickbox" href="<?php echo $team_link; ?>">More info <?php// echo $first_name[0]; ?></a></p>
  43. <?php if ($team_email) : ?><p><a href="mailto:<?php echo $team_email;?>">Email <?php echo $first_name[0]; ?></a></p><?php endif; ?>
  44. </div>
  45. </div> <?php
  46. endwhile;
  47. }
  48. }
  49. }
  50.  
  51. //reset terms
  52. if( is_array( $_POST['genres'] ) && count( $_POST['genres'] ) ){
  53. $_POST['genres_order'] = ( $_POST['genres'] = array_map( 'intval', $_POST['genres'] ) );
  54. wp_set_object_terms( $_POST['ID'], $_POST['genres'], 'nv_genre', false ); //will replace any previous genres
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement