WordPress.org

Forums

[resolved] Display custom hierarchical taxonomies in hierarchical bullet format (2 posts)

  1. Please Add Screenshots
    Member
    Posted 1 year ago #

    I'm not sure but... it appears the latest update 3.7/3.8 has changed how this piece of code works (I'm sure it worked fine in 3.6x). As the title of the posts say... I want to display the custom hierarchical taxonomy as per it's hierarchical structure/format in bullet form.

    This is the code...

    <ul><?php
        $taxonomy = 'program';
        $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
        $separator = ' ยป ';
        if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
                $term_ids = implode( ',' , $post_terms );
                $terms = wp_list_categories( 'title_li=&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids  );
                $terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );
                echo  $terms;
        }
        ?></ul>

    This is what I would like the code to display...

    • Parent taxonomy
      • Child taxonomy
        • Grandchild taxonomy 1
        • Grandchild taxonomy 2

    Unfortunately this is wha he code displays...

    • Child taxonomy
      • Grandchild taxonomy 1
      • Grandchild taxonomy 2
    • Parent taxonomy

    Any help greatly appreciated!

    Regards, Pete

  2. Please Add Screenshots
    Member
    Posted 1 year ago #

    It appears a taxonomy ordering plugin was interfering with it.

Topic Closed

This topic has been closed to new replies.

About this Topic