• shellyd

    (@shellyd)


    I’m diving into custom taxonomies for the first time and am having trouble. Any help is welcome.

    I’ve got a custom content type (videos), and a custom taxonomy (vidcat) for those videos. There are 3 parent categories in that taxonomy (Age, Type, Language) and each parent has 2-3 children. For example, Type has 2 children: Song and Rhyme.

    On the home page, I’d like to display a list of video titles with the child of Type next to it. E.g.

    • Itsy bitsy spider: SONG
    • Alphabet Monster: RHYME

    When I first started this project, I was using WP’s standard Categories instead of Custom Taxonomy, and was able to achieve what I wanted using the following code to call the child of Type (id=18):

    <?php
                                        foreach((get_the_category()) as $childcat) {
                                        if (cat_is_ancestor_of(18, $childcat)) {
                                        echo '<a href="'.get_category_link($childcat->cat_ID).'">';
                                         echo $childcat->cat_name . '</a>';
                                        }}
                                        ?>

    I’m not sure how to modify the above code to work with custom taxonomies. Any ideas?

    Sidenote: My initial thought was to make 3 Taxonomies instead of parent categories, but this is a conversion project (Drupal to WP), and without getting into the details I’ll just say that leaving the existing category structure in place is important to the project.

  • The topic ‘Show child of custom taxonomy in the loop’ is closed to new replies.