Support » Themes and Templates » Custom parent taxonomy and subcategory

  • Resolved rolyestemonio


    I really need your help. i just created a WordPress page template that display all the post but my problem is the display of the custom parent taxonomy/category and it’s children. My post look like this.

            <td>Parent Category</td>
            <td>Sub Category</td>
            <td>a title</td>
            <td>USA custom category</td>
            <td>Hawaii uder USA</td>
            <td>this is a sample description.</td>

    My only problem is to display the sub category. Anyone can help me?

    This is my code on how i display the parent custom category:

            $term_list = '';
            $terms     = get_the_terms( $post->ID, 'origincity' );
            foreach( $terms as $term ) {
                $parent_term = get_term( $term->parent, 'origincity' );
                $term_list  .= $parent_term->name ;
            echo $term_list;

    I tried to display the sub category by this code :

    <?php $terms2 = wp_get_post_terms($post->ID, 'origincity', array("fields" => "all"));
        foreach ($terms2 as $term1) {
            echo $term1->name.'<br>';
        } ?>

    but it also return the parent. 🙁

    Your help is highly appreciated. Thanks.

  • The topic ‘Custom parent taxonomy and subcategory’ is closed to new replies.