Get the category name from the slug? Help needed please
-
Hi guys,
Im trying to display the category name from the slug as a title on my taxonomy page. Im using the excellent Query Multiple Taxonomies plug-in that allows you to filter posts in a category by the taxonomy terms associated with them.
For example, if i had a category of clothes, and some taxonomies of colours and sizes, you could then use the plug-in to show all posts that were in the category of clothes, the colour of red, and the size of small. The url would then display something like this:
mysite.com/?category_name=clothes&colour=reds&size=small
On the taxonomy page i would like a heading that shows the category_name based on the slug. So in this case it would echo ‘clothes’. Does anyone know how to do this?
At the moment i have tried two pieces of code, one that unfortunately shows all the queries:
<?php if (is_multitax()) { foreach ( qmt_get_query() as $tax => $slug ) { $terms[] = get_term_by( 'slug', $slug, $tax )->name; } ?> <h1><?php echo implode( ", ", $terms ); ?></h1> <?php } ?>
and the other that shows only the last selected term:
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); echo $term->name; ?>
neither of these are what im looking for. Any help would be much appreciated. Thanks
- The topic ‘Get the category name from the slug? Help needed please’ is closed to new replies.