• Hello,

    I’ve created a custom post type, “Available Candidates”, and I’ve created two custom taxonomies for this post type, “Industry” and “State”. I have a custom page listing each State term and each State term links to it’s corresponding taxonomy archive page, listing the “Available Candidates” posts within this taxonomy.

    This works great, but now I’d like to loop through each Industry taxonomy listing each “Available Candidate” post under each Industry within each State. The loop is built and works great but as of now every “Available Candidates” post is listed here. I need to query these posts by the current State taxonomy archive.

    Pennsylvania Archive Page:

    • Industry
    • Candidate 1
    • Candidate 2
    • Industry
    • Candidate 1
    • Candidate 2
    • Industry
    • Candidate 1
    • Candidate 2

    Maryland Archive Page:

    • Industry
    • Candidate 1
    • Candidate 2
    • Industry
    • Candidate 1
    • Candidate 2
    • Industry
    • Candidate 1
    • Candidate 2

    Here’s my taxonomy page code.

    <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
    
    	<h1><?php echo $term->name; ?></h1>
    
    	<?php
    	$tax = 'industry';
    	$tax_terms = get_terms($tax);
    
    	if ($tax_terms) {
    
    		foreach ($tax_terms  as $tax_term) {
    
    			$args=array(
    			"$tax" => $tax_term->slug,
    		      	'post_status' => 'publish',
    		      	'posts_per_page' => -1,
    		      	'caller_get_posts'=> 1
    		    );
    
    			$my_query = null;
    			$my_query = new WP_Query($args);
    
    			if( $my_query->have_posts() ) {
    			?>
    
    				<div>
    
    					<h2><?php echo($tax_term->name); ?></h2>
    
    					<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    						<!-- post-<?php the_ID(); ?> -->
    						<article id="post-<?php the_ID(); ?>">
    
    							<header>
    
    								<h3><?php the_title(); ?></h3>
    
    						    </header>
    
    					    	<div>
    
    								<?php the_content(); ?>
    
    							</div>
    
    						</article>
    						<!-- /post-<?php the_ID(); ?> -->
    
    					<?php endwhile; ?>
    
    				</div>
    
    			<?php
    			} // end if
    
    			wp_reset_query();
    
    		} // end for each
    
    	} // end if
    	?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Query Multiple Taxonomies in Taxonomy Archive Template’ is closed to new replies.