• I need to display a list of taxonomy terms, but only those which have posts with status “published”. ie: if a term has no publicly available posts, then I don’t want it displayed. I am using get_terms() and it is displaying *all* terms in the taxonomy — even terms that only have “private” or “draft” or “pending review” posts.

    Here is some sample code:

    $regions = get_terms("region");
    foreach ( $regions as $region) {
        echo "<li>" . $region->name . " : ". $region->slug ."</li>
    ";
    }

    Can someone suggest how I can modify this code to bring up only the taxonomy terms will published posts??

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to use get_terms to show only published posts?’ is closed to new replies.