Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php //for a given post type, return all
- $post_type = 'our-team';
- $tax = 'team-categories';
- $tax_terms = get_terms($tax);
- if ($tax_terms) {
- foreach ($tax_terms as $tax_term) {
- $args=array(
- 'post_type' => $post_type,
- "$tax" => $tax_term->slug,
- 'post_status' => 'publish',
- 'posts_per_page' => -1,
- );
- $my_query = null;
- $my_query = new WP_Query($args);
- if( $my_query->have_posts() ) {
- echo '<h2 style="clear:both;">'.$tax_term->name.'</h2>';
- while ($my_query->have_posts()) : $my_query->the_post();
- //set vars for custom fields
- $team_location = get_field('team_location');
- $team_position = get_field('team_position');
- $team_email = get_field('team_email');
- $team_name = get_the_title();
- $team_link = get_permalink();
- //get only first name. usage: echo $first_name[0];
- $team_first_name = $team_name;
- $first_name = explode(' ', trim($team_first_name));
- ?>
- <div class="team_member">
- <?php if ( has_post_thumbnail()) { ?>
- <a class="thickbox" href="<?php echo $team_link; ?>"><?php the_post_thumbnail('medium'); ?></a>
- <?php } else { ?>
- <img src="<? bloginfo('template_directory' );?>/library/images/no_pic.jpg" alt="no image provide" />
- <?php } ?>
- <div class="team_member_info">
- <h2><?php the_title();?></h2>
- <p><a class="thickbox" href="<?php echo $team_link; ?>">More info <?php// echo $first_name[0]; ?></a></p>
- <?php if ($team_email) : ?><p><a href="mailto:<?php echo $team_email;?>">Email <?php echo $first_name[0]; ?></a></p><?php endif; ?>
- </div>
- </div> <?php
- endwhile;
- }
- }
- }
- //reset terms
- if( is_array( $_POST['genres'] ) && count( $_POST['genres'] ) ){
- $_POST['genres_order'] = ( $_POST['genres'] = array_map( 'intval', $_POST['genres'] ) );
- wp_set_object_terms( $_POST['ID'], $_POST['genres'], 'nv_genre', false ); //will replace any previous genres
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement