How to count the number of terms in a taxonomy

As @shanebp suggests, you could use wp_count_terms() like this: $numTerms = wp_count_terms( ‘service-category’, array( ‘hide_empty’=> false, ‘parent’ => 0 ) ); The above will list All top parent terms, empty or not. This function uses get_terms() functions arguments which can be found in the link or the arguments below: $args = array( ‘orderby’ => ‘name’, … Read more

How to add taxonomy to Users menu in admin?

The register_taxonomy function is designed only for adding taxonomies to existing post types and custom post types. It’s not something that can be expanded to users. I have just tried a couple of plugins that work with taxonomies and neither are able to attach a taxonomy to a user. from http://codex.wordpress.org/Function_Reference/register_taxonomy : Usage <?php register_taxonomy( … Read more

How do I sort posts by custom taxonomy?

If I understand your question correctly, I think I may have your answer in this blog post: https://evowebdev.com/2017/05/using-a-dropdown-menu-to-filter-a-custom-post-type-with-custom-taxonomy/ This solution specifically uses select form element auto-populated with taxonomy terms to sort CPT posts (ie, rather than presorting posts with pre_get_posts, it lets site visitors sort by the taxonomy term[s] they select). If it’s really important … Read more