I would like to create a custom archive page (taxonomy.php) for my Custom Taxonomies, where the posts are displayed in lists, grouped by Post Type.
I have three Post Types: -
- Post
- Report (Custom Post Type)
- Guide (Custom Post Type)
I also have two Custom Taxonomies: -
- Sales Territory (Terms are a list of business sectors)
- Technical Area (Terms are a list of Technical 'Topics')
How would I best approach this?
I have achieved something similar on a custom page template, where I have grouped a certain category of my Guides Custom Post Type by my Technical Area Custom Taxonomy terms (code below), but I can't translate this to work the way I described above.
<?php
foreach ( $technical_area_terms as $technical_area_term ) {
$member_group_query = new WP_Query( array(
'post_type' => 'guides',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'technical_area',
'field' => 'slug',
'terms' => array( $technical_area_term->slug ),
),
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array( 'p1000-guides', 'guides'),
)
)
) );
?>
<h2><a href="../../../technical_area/<?php echo $technical_area_term->slug; ?>"><?php echo $technical_area_term->name; ?></a></h2> <!-- Technical Area Title -->
<?php
if ( $member_group_query->have_posts() ) : ?>
<table>
<tr>
<th>Title</th>
<th>Issue</th>
<th>Date</th>
</tr> <?php
while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
<tr>
<td><?php the_title( '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' , '</a>' ); ?></td>
<td></td>
<td><?php the_time( get_option( 'date_format' ) ); ?></td>
</tr>
<?php endwhile; ?>
</table>
<?php else: ?>
No content
<?php endif; ?>