WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using the following code to create a list of linked terms belonging to a taxonomy.

$taxonomy = 'taxonomy_name';
$queried_term = get_query_var($taxonomy);
$terms = get_terms($taxonomy, 'slug='.$queried_term);
if ($terms) {
  echo '<ul>';
  foreach($terms as $term) {
    echo '<li><a href="'.get_term_link($term->slug, $taxonomy).'">'.$term->name.'</a></li>';
  echo '</ul>';

Is there a way that I can modify this so that once a term is selected/clicked and the archive is shown, the term list will then only show terms that are also attached to posts in the current term archive - effectively like a filtering/drill-down system?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.