Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cyberhobo/436653deba70b710a3e5 to your computer and use it in GitHub Desktop.
Save cyberhobo/436653deba70b710a3e5 to your computer and use it in GitHub Desktop.
<?php
// First, read the reads
$materials = wp_get_post_terms( get_the_ID(), 'acme_materials' );
$child_count = array_reduce( $materials, function( $count, $material ) {
return $count + count( get_term_children( $material->term_id, 'acme_materials' ) );
});
if ( $child_count > 0 ) {
// Some term has children
} else {
// No terms have children
}
@cyberhobo
Copy link
Author

Closure version - requires PHP 5.3!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment