Viewing 1 replies (of 1 total)
  • $categories = get_the_terms($post->ID, 'category' );
    $top_level_ids = [];
    foreach( $categories as $category ) {
        if( ! $category->parent ) {
            $top_level_ids[] = $category->term_id;
        }
    }
    foreach( $categories as $category ) {
        if( in_array($category->parent_id, $top_level_ids)) {
            echo $category->term_id . ', ' . $category->slug . ', ' . $category->name . '' . <strong>$category->description</strong> . '<br />';
        }
    }
Viewing 1 replies (of 1 total)
  • The topic ‘second categorie’ is closed to new replies.