Having some trouble with a custom taxonomy archive template
-
Hello all, I’m having a little trouble with a custom taxonomy template. I inherited a site that was developed by someone else and they use “Types” plugin to add some custom taxonomies.
Goal example: to have an archive template that shows only posts with a certain taxonomy term in it at <domain>/people/harrison-ford
Problems:
1) This code is bringing in posts that do not have the taxonomy selected.2) This is not returning the name for some reason: <?php echo $tax_term->name; ?> News</h2>
Here’s my code:
<?php $year = get_post_meta($post->ID, 'year', true); $post_type = 'post'; $tax = 'people'; $tax_terms = get_terms( $tax ); if ($tax_terms) { $args = array( 'post_type' => $post_type, 'people' => 'harrison-ford', "$tax" => $tax_term->slug, 'post_status' => 'publish', 'posts_per_page' => -1, 'caller_get_posts'=> 1, 'orderby' => 'date', 'order' => DESC ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) : ?> <h2 class="wwNews"><?php echo $tax_term->name; ?> News</h2> <?php while ( $my_query->have_posts() ) : $my_query->the_post(); ?> <-- display stuff --> <?php endwhile; // end of loop ?> <?php endif; // if have_posts() wp_reset_query(); } ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Having some trouble with a custom taxonomy archive template’ is closed to new replies.