• I have a custom taxonomy(the taxonomy is types) that is basically a selector that tells WordPress which section of the site to place the new post.

    So for example

    1. I create a new post and select Lifestyle from the custom taxonomy list.
    2. Then I would select a category to place the post under, for example Healthy

    I am trying to list the categories of Lifestyle in a custom menu format but only if posts exist under the taxonomy type and category selected.

    What I am getting is a full list of categories but not filtered by taxonomy type.

    Can anyone see where I have gone wrong?

    <?php
    $args=array(
      'types' => 'Lifestyle',
      'orderby' => 'name',
      'order' => 'ASC',
      'hide_empty' => 1
      );
    $categories=get_categories($args);
      foreach($categories as $category) {
        if ($category->count > 0){
        echo '<li class="'.$category->slug.'"><a href="?category=' . $category->slug . '">'.$category->name.' / '.$category->count.'</a></li>';
            }
        }
    ?>

    Thanks so much in advance!
    -d

  • The topic ‘Get Categories Where Taxonomy Equals 'n'’ is closed to new replies.