Support » Plugins » Hacks » Displaying terms of a selected taxonomy on page refresh

  • let me try to explain what I’m hoping to accomplish. This is for testing purposes, I have a taxonomy I’ve named location, and I want to populate a dropdown list of it’s parent terms. Depending on which parent term is selected, the child terms of the parent should display in an unordered list on page refresh.

    This is what I’m currently using to list all of the child terms of the taxonomy, loacation:

    $taxonomyName = "location";
    $terms = get_terms($taxonomyName,array('parent' => 0));
    foreach($terms as $term) {
        $term_children = get_term_children($term->term_id,$taxonomyName);
        echo '<ul>';
        foreach($term_children as $term_child_id) {
            $term_child = get_term_by('id',$term_child_id,$taxonomyName);
        echo '<li>'.$term_child->name.'</li>';
        echo '</ul>';

    What I’d like to do is filter the unordered list of child terms based off the parent term selected within a dropdown, displaying only the child terms of the parent term selected on page refresh.

    Any help would be much appreciated. Thank You!

  • The topic ‘Displaying terms of a selected taxonomy on page refresh’ is closed to new replies.