I want to build a page with the members of a team. Because I have too many members, I want to group them by department. Therefore, I created a custom post type TEAM with taxonomy by department
I use the following code to display the team members. I created a new page template.
<?php
$team_posts = get_posts( array(
'post_type' => 'team',
'posts_per_page' => -1, // Unlimited posts
'orderby' => 'title', // Order alphabetically by name
) );
foreach ( $team_posts as $post ):
setup_postdata($post);
$thumb_src = null;
if ( has_post_thumbnail($post->ID) ) {
$src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'team-thumb' );
$thumb_src = $src[0];
}
?>
<article class="seven columns team_lid">
<div class="tm_header">
<?php if ( $thumb_src ): ?>
<img src="<?php echo $thumb_src; ?>" alt="<?php the_title(); ?>, <?php the_field('team_position'); ?>" class="img-circle">
<?php endif; ?>
</div>
<div class="tm-content">
<h3><?php the_title(); ?></h3>
<p class="lead position"><?php the_field('team_position'); ?></p>
<i class="fa fa-mobile contact_icoon"></i><?php the_field('team_phone'); ?><br/>
<i class="fa fa-mobile contact_icoon"></i><?php the_field('mobile_phone'); ?><br/>
<i class="fa fa-envelope contact_icoon"></i><a href="<?php the_field('team_email'); ?>"><?php the_field('team_email'); ?></a>
<div class="content_tekst">
<?php the_content(); ?>
</div>
</div>
</article><!-- END seven columns -->
<?php endforeach; ?>
This is all working well, but as you can see this code displays all the team members no matter in which department they are.
Can somebody help me with this matter? I want to have the different departments with the team members on 1 page template. Which functions do I have to use.
$team_posts
variable.