I use a lot of custom sidebars, which require looking at what category is being displayed and then returning certain content. Currently, I am using the following:
<?php $category = get_the_category($post->ID); $incname = $category->category_nicename; include(TEMPLATEPATH.'/zList'.ucfirst($incname).'.php'); ?>
However, this requires looking at the actual posts and not the category slug. This causes problems sometimes. I found the get_terms_by function and wrote the following, which does not seem to work:
<?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $incname = $term->slug; include(TEMPLATEPATH.'/zList'.ucfirst($incname).'.php'); ?>
How can I get this to work? For both categories, tags, and custom taxonomies?
- The topic ‘Get archive page's slug/name’ is closed to new replies.