WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_categories won't hide empty taxonomy terms (2 posts)

  1. kbiglione
    Member
    Posted 4 years ago #

    I'm using wp_list_categories to display a list of custom taxonomy terms. I would expect terms that are not associated with a published post to be hidden. That isn't the case. I've tried setting hide_empty=1 (even thought that's the default) with no luck.

    Looking for a workaround...

  2. semrocc
    Member
    Posted 3 years ago #

    Yes, I'm looking for a workaround on a similar scenario. I use the code below to call the list, which only shows the taxonomy terms that are active...the only problem is that the list shows a taxonomy term when it is tied to a draft. How can I show just the terms that are tied to published posts?

    <?php
    $taxonomy     = 'people';
    $orderby      = 'name';
    $show_count   = 1;      // 1 for yes, 0 for no
    $pad_counts   = 0;      // 1 for yes, 0 for no
    $hierarchical = 1;      // 1 for yes, 0 for no
    $title        = '';
    
    $args = array(
      'taxonomy'     => $taxonomy,
      'orderby'      => $orderby,
      'show_count'   => $show_count,
      'pad_counts'   => $pad_counts,
      'hierarchical' => $hierarchical,
      'title_li'     => $title
    );
    ?>
    
    <ul>
    <?php wp_list_categories( $args ); ?>
    </ul>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.