• WebStyley

    (@webstyley)


    Hello,

    I would like to organize the current posts taxonomies in a list with parent – child taxonomy terms.

    For instance, I would like a structure like this:

    Term
    -Term Child
    –Term Grandchild
    —Term Great Grandchild
    Term
    -Term Child
    –Term Grandchild
    —Term Great Grandchild

    Here is the code I have been working with, but have come to a roadblock trying to achieve this. Thanks in advance.

    <ul style="
        font-size: 20px;
        -webkit-column-count: 4;
        -moz-column-count: 4;
        column-count: 4;
    	text-align: left;
    "><p style="font-weight: none; font-size: 10px;"><?php
    $args = array('orderby' => 'term_group', 'order' => 'ASC', 'fields' => 'all');
    $product_terms = wp_get_object_terms( $post->ID, 'zip-code' );
    if ( ! empty( $product_terms ) ) {
    	if ( ! is_wp_error( $product_terms ) ) {
    
    			foreach( $product_terms as $term ) {
    				echo '<a href="' . get_term_link( $term->slug, 'zip-code' ) . '">' . esc_html( $term->name ) . '</a> , ';
    			}
    
    	}
    }
    ?></p></ul>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Ordering Current Post Taxonomy Terms’ is closed to new replies.