Forked from tommcfarlin/1-check-if-term-has-children.php
Last active
August 29, 2015 14:12
-
-
Save cyberhobo/436653deba70b710a3e5 to your computer and use it in GitHub Desktop.
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 | |
// 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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Closure version - requires PHP 5.3!