Last active
March 3, 2017 02:49
-
-
Save brooke-heaton/6755b15e6357f4bc27bf8419105af642 to your computer and use it in GitHub Desktop.
Get Count of Taxonomy Terms per Vocabulary ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This Drupal 7 helper function will return and echo the count of | |
* taxonomy terms by vocabulary | |
* @param $vid - integer for vocabulary id | |
*/ | |
function GetCountTaxonomyTermsByVocab($vid) { | |
$query = new EntityFieldQuery; | |
$terms = $query | |
->entityCondition('entity_type', 'taxonomy_term') | |
->propertyCondition('vid', $vid) | |
->execute(); | |
$count_terms = count($terms['taxonomy_term']); | |
echo "There are $count_terms terms in the $vid Vocabulary\n"; | |
return $count_terms; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment