Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active October 28, 2023 00:14
Show Gist options
  • Save tommcfarlin/6e5445d9d3d45da14fcf to your computer and use it in GitHub Desktop.
Save tommcfarlin/6e5445d9d3d45da14fcf to your computer and use it in GitHub Desktop.

Revisions

  1. tommcfarlin revised this gist Jan 6, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1-check-if-term-has-children.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    foreach ( $materials as $material ) {

    if ( count( get_term_children( $material->term_id, 'acme_materials' ) ) > 0 ) {
    // The term has no children
    // The term has children
    }

    }
  2. tommcfarlin created this gist Jan 5, 2015.
    11 changes: 11 additions & 0 deletions 1-check-if-term-has-children.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?php
    // First, read the reads
    $materials = wp_get_post_terms( get_the_ID(), 'acme_materials' );

    foreach ( $materials as $material ) {

    if ( count( get_term_children( $material->term_id, 'acme_materials' ) ) > 0 ) {
    // The term has no children
    }

    }
    11 changes: 11 additions & 0 deletions 2-check-if-term-has-no-children.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <?php
    // First, read the reads
    $materials = wp_get_post_terms( get_the_ID(), 'acme_materials' );

    foreach ( $materials as $material ) {

    if ( count( get_term_children( $material->term_id, 'acme_materials' ) ) === 0 ) {
    // The term has no children
    }

    }