Support » Plugins » Hacks » count terms function, output is missing a taxonomy

  • Resolved amandathewebdev

    (@amandathewebdev)


    Hi all,

    I am creating a filterable portfolio. I’m using wp_count_terms to count the number of terms (taxonomies) in my cpt specialty. The output is 2 out of the 3 terms. There IS a post under the 3rd missing taxonomy, so that shouldn’t be the issue. Could anyone help me figure out why I’m missing a taxonomy?

    <?php
    $terms = get_terms("specialty"); //taxonomy of cpt
    $count = wp_count_terms($terms);
    echo '<ul id="portfolio-filter">';
        echo '<li><a href="" rel="all" title="" class="filter">All</a></li>';
            if ( $count > 0 ){
                 foreach ( $terms as $term ) {
    	        $termname = strtolower($term->name);
    	        $termname = str_replace(' ', '-', $termname);
    		
                    echo '<li><a href="" class="filter" title="" rel="'.$termname.'">'.$term->name.'</a></li>';
    	     }
            }
    	echo "</ul>";
    ?>
Viewing 1 replies (of 1 total)
  • Thread Starter amandathewebdev

    (@amandathewebdev)

    I hate when I finally get so stuck I ask a question and then figure it out moments later! I mean, I’m glad I figured it out, but ugh.

    So I changed the first line to:
    $terms = get_terms( 'specialty', array('hide_empty' => false,) );

    And that did the trick. I also realized my post in that third category wasn’t in the correct category.

Viewing 1 replies (of 1 total)
  • The topic ‘count terms function, output is missing a taxonomy’ is closed to new replies.