Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,
    nice plugin !
    Got exactly the same problem though:(

    Plugin Author nsp-code

    (@nsp-code)

    Hi
    Sorry for this functionality is currently available only for advanced version. However you can use get_terms instead then filter out the terms you don’t need to include.

    For Nico, I solved my problem using get_terms.
    My former code :

    $termID = $cat_id; // Parent A ID
      $taxonomyName = "event-category";
      $termchildren = get_term_children( $termID, $taxonomyName );
    
    foreach ($termchildren as $child) {
    
    $term = get_term_by( 'id', $child, $taxonomyName );
     $term_slug = $term->slug;
    $term_tax_id = $term->term_id;
    
    echo "<h2><a href='".get_term_link( $term )."'>".$term->name."</a></h2>";
    
      $events = eo_get_events(array(
              'numberposts'=>-1,
              'showpastevents'=>true,//Will be deprecated, but set it to true to play it safe.
    		  'event-category'=>$term_slug
         ));
    
    	 if($events):
              echo '<ul>';
              foreach ($events as $event):
    		  $custom_terms = get_terms('event-category');
    
                   //Check if all day, set format accordingly
                   $format = ( eo_is_all_day($event->ID) ? get_option('date_format') : get_option('date_format').' '.get_option('time_format') );
                   echo '<li>';
    			   echo '<a href="'.get_permalink($event->ID).'">'.get_the_title($event->ID).'</a> - '.eo_get_the_start($format, $event->ID,null,$event->occurrence_id);
    			   echo '</li>';
    
              endforeach;
              echo '</ul>';
    		 endif;

    Corrected Code

    $termID = $cat_id; // Parent A ID
        $taxonomyName = "event-category";
        $termchildren = get_terms( $taxonomyName, array( 'child_of' => $termID, 'orderby'       =>  'term_order',
                    'hide_empty'    => false ) );
    //	get_term_children( $termID, $taxonomyName );
    
              foreach ($termchildren as $child) {
    			  $term_slug = $child->slug;
    			  $term_tax_id = $child->term_id;
    			  $tag_desc = $child->description;
    
    echo "<h2><a href='".get_term_link( $child )."'>".$child->name."</a></h2>";
    
    						if ( ! empty( $tag_desc ) )
    							echo $tag_desc;
    Thread Starter Nico Martin

    (@nico_martin)

    That works great! Thank you!!
    I only had to adjust my code because get_terms() returns the terms and get_term_children() returns the term IDs. But now its works!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_term_children order’ is closed to new replies.