Through landing we are showing categories. Clicking on any category show child sub categories. But this shows child of child as well. following is our code to retrieve sub categories.

$terms = get_terms( 'msproduct' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
    echo '<ul>';
    foreach ( $terms as $term ) {
        echo '<li>' . $term->name . '</li>';
    }
    echo '</ul>';
}

please advice. My category structure is following

Commercial Ovan
- 900 Series
-- Product 1
-- Product 2
- 700 Series
-- Product 1
- 600 Series
-- Product 1
-- Product 2
-- Product 3
-- Product 4

Read more here: Custom post type with taxonomy children


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: