I’ve created a custom post type and a custom taxonomy to go with it.
I can’t figure out how to program the loop on the taxonomy-{taxonomy}.php template to make it only show the posts that correspond with the current taxonomy archive page someone is on. <domain>taxonomy/term
I have created a loop that does filter based on taxonomy, however, its not dynamic, the loop works for whichever term of the custom taxonomy I program it to.
I would love a way to have it know which taxonomy archive (based on url?) the user is on, and only show posts from that taxonomy without having to create a template for each taxonomy term.
Current Loop:
<?php
$args = array( 'post_type' => 'event', 'type' => 'party', 'post_status' => 'future', 'posts_per_page' => 50, 'order' => 'ASC' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();?>
<div class="event-item">
<div class="event-meta gold">
<div class="event-date"><?php the_time('M d'); ?></div>
<div class="event-time"><?php the_time('g:i A'); ?></div>
</div>
<div class="event-title">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
<?php the_title(); ?>
</a>
</div>
<div class="entrytext">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
Summary: having party be replaced with something that can change it based on which page a user is on would be spectacular!
Try using
get_query_var('tag'), where ‘tag’ is the name of your custom taxonomy and add there result of that query to your $args.I use it to create a tags archive page that changes display based on what tag I’m currently in.