Get Number of total Parent Categories for Custom Taxonomy

I am running an artist feature blog where I do interview artists from different countries and post some travel stuff from different countries.

I’ve set up a Custom Taxonomy called “Artist Name“. This is only used on Interviews. The parent categories are different countries (Germany, US, France, China, etc.), the child categories are cities. I use categories on all posts (interviews and travel stuff).

Read More

I made a statistics page template where I want to show the total number of countries where my interviewees are from. In addition, I want to show the total number of countries where I’ve traveled to.

  1. Is it possible to get the total number of all PARENT categories of posts that use that custom taxonomy?
  2. Is it possible to get the total number of all PARENT categories of posts that do NOT use that custom taxonomy (e.g. when Artist Name is blank)?

I already tried to use some code snippets I found including:

count(get_categories('parent=0&hide_empty=0')

Related posts

Leave a Reply