Passing queried taxonomy
-
I hope I’m posting this in the right forum…
In my theme, I created a page that lists all terms from a taxonomy, this then links to a page that displays all posts of that taxonomy, each item is then linked to their respective post. The taxonomy template uses
<?php single_term_title(''); ?>
to display the queried taxonomy term name. How can I pass that queried taxonomy term to the single page template to then be used?I tried using the
<?php single_term_title(''); ?>
but that didn’t seem to work. I’m sure it’s a simple bit of code, but I can’t find it in all my searching.Additional information
This is for a custom post type, “Services” with custom taxonomy, “Locations”.Here’s the part that lists my taxonomies:
<?php $terms = get_terms('locations'); $temp = ''; foreach($terms as $term): $title = $term->name; $first_letter_lower = strtolower(substr($title, 0, 1)); if($temp != $first_letter_lower){ echo '<div class="locations-'.$first_letter_lower.'">'; $temp = $first_letter_lower; } $first_letter = strtoupper(substr($title, 0, 1)); if($temp != $first_letter){ echo '<h3>'.$first_letter.'</h3><hr />'; $temp = $first_letter; } ?> <ul> <li><a href="<?php echo get_term_link($term);?>"><?php echo $term->name ;?></a></li> </ul> <?php endforeach;?>
Here’s the part for the taxonomy page template:
<?php if ( have_posts() ) : ?> <header class="archive-header"> <h1 class="archive-title"> <?php single_term_title('Services in '); ?> </h1> </header><!-- .archive-header --> <ul> <?php while ( have_posts() ) : the_post();?> <li> <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a> </li> <?php endwhile;?> </ul> <?php else : ?> <?php get_template_part( 'content', 'none' ); ?> <?php endif; ?>
- The topic ‘Passing queried taxonomy’ is closed to new replies.