Using custom taxonomy with query_posts on taxonomy.php template
-
Hi
I need a bit of help with automating my taxonomy.php template if possible. I’ve created a custom post type and a new taxonomy to go with it, I’ve then added some terms (categories) to it. What I want my taxonomy.php page to do is to show only the posts tagged with the current term to show on each page… so:Custom post type: Athletes
Taxonomy: Sports
Terms: Swimming, Athletics etc etcSo when you go to …com/sports/swimming it shows all the posts from the athletes custom post type that are in the category swimming.
This is the code I’d ideally like, capitals show the generated values required, depending if you are on swimming, or athletics page etc.
<?php $args = array( 'post_type' => 'athletes', 'CURRENT_PAGE_TAXONOMY' => 'CURRENT_PAGE_TAXONOMY_TERM', 'posts_per_page' => -1 ); query_posts( $args );while ( have_posts() ) : the_post(); ?>
Does anyone know a way to do this? I’ve tried a few versions of other peoples code, but just can’t get it to do what I need, I’m using
<?php $term = $wp_query->queried_object;echo ''.$term->name.'';?>
to show the page title correctly, but then need the relevant posts underneath..
Help!
- The topic ‘Using custom taxonomy with query_posts on taxonomy.php template’ is closed to new replies.