WordPress.org

Ready to get started?Download WordPress

Forums

Display taxonomy 2nd & 3rd level terms (1 post)

  1. binga30
    Member
    Posted 1 year ago #

    Hello,

    I have a custom taxonomy called location. Under location I have arranged a structure like so:

    >state
    >>region
    >>>city

    I would like to be able to output these terms in hierarchical order and be able to add my own links to these instead of these linking to the archive page of these terms.

    So far I have code to output the state which is allowing me to add my own href:

    <?php
    								//display state
    echo '<ul class="location">';						$taxonomyName = "location";
    $terms = get_terms($taxonomyName,array('parent' => 0));
    								foreach($terms as $term) {
    
    echo '<li><a class="state" href="#">'.$term->name.'</a></li>';
    }
    echo '</ul>';
    // end state
    ?>

    How can i specifically grab only the second level term, or third level term?

    I realise this is a roundabout way, but using any of the commands like get_terms, _wp_list_categories, get_the_term_list etc.... they all output the taxonomy either not in order, or with their own links to the taxonomy which is not what I want.

    Would be great to hear some tips or pointers on the matter.

    Regards

    Steve

Topic Closed

This topic has been closed to new replies.

About this Topic