View difference between Paste ID: Akx1edbp and bC5hNFpx
SHOW: | | - or go back to the newest paste.
1
/* Loop through each category "team" and output the posts */
2
3
        // establish the category arguments
4
        $cat_args = array(
5
            'taxonomy' => 'team', // we must specify the custom taxonomy we created as part of the staff CPT
6
            'orderby' => 'slug', // this allows us to put a custom slug in to create our own custom order i.e. 01_team-name
7
            'order' => 'ASC'
8
        );
9
10
	$cats = get_categories($cat_args); // passing in above parameters
11
12
            foreach ($cats as $cat) : // loop through each cat
13
14
                $cpt_query_args = array(
15
                    'post_type' => 'staff',
16
                    'cat' => $cat->cat_id
17
                );
18
19
                query_posts($cpt_query_args); //create our own custom query based on above arguments
20
21
                    if (have_posts()) :
22
                        echo '<h2 class="team-title">'.$cat->name.'</h2>';
23
                        while (have_posts()) : the_post(); ?>
24
                            <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
25
                                <?php the_post_thumbnail('staff-photo'); ?>
26
                                <h3 class="staff-name"><?php the_title(); ?></h3>
27
                                <div class="staff-tenure"><?php echo $_arcpc_tenure; ?></div>
28
                                <?php the_content(); ?>
29
                            </div>
30
                <?php endwhile; endif; wp_reset_query();
31
            endforeach;