0

I have a content type where a taxonomy term is associated to it . I would like to know how could i count the number of content types by taxonomy term ?

2
  • do you mean you want to get count of nodes of particular content type by a specific term? Nov 5 '12 at 10:09
  • @AnoopJoseph yes!
    – Vlasin
    Nov 5 '12 at 10:18
1

You can use the following snippet, to get count of nodes by passing the term id

<?php
  $tids = array(1); //An array of term IDs to match.
  $nodes = taxonomy_select_nodes($tids);
  echo count($nodes) ;
?>

Edit:

You can use views to achieve this, check this similar question . It explains an example

2
  • I have a list of terms and i would like to show the number of nodes next to the term name...
    – Vlasin
    Nov 5 '12 at 10:27
  • i edited answer please checkout the similar question Nov 5 '12 at 10:32
0

You can try Term Node Count module. Though it is still for Drupal 6, but you will find the Drupal 7 compatible version from this discussion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.