WordPress.org

Forums

Display/show/list custom terms in heirarchy order - not alphanumerical (11 posts)

  1. I like screenshots
    Member
    Posted 1 year ago #

    Can anyone be able to tell me....

    1. why these 3 pieces of code DON'T display/list show my custom hierarchial terms in hierarchy order?
    2. how I can make them display/show/list in hierarchial order

    All 3 do basically the same thing but they all in alphanumercial order rather hierarchy order.

    Thanks heaps, Pete

    #1

    <?php echo '<ul class="styles">';
    echo get_the_term_list( $post->ID, 'program', '<li>', ',</li><li>', '</li>' );
    echo '</ul>'; ?>

    #2
    <?php echo get_the_term_list( $post->ID, 'program', 'Program: ', ', ', '' ); ?>

    #3
    <?php the_terms( $post->ID, 'program', 'Program: ', ' / ' ); ?>

  2. keesiemeijer
    moderator
    Posted 1 year ago #

  3. I like screenshots
    Member
    Posted 1 year ago #

    I've already tried that with no luck

  4. keesiemeijer
    moderator
    Posted 1 year ago #

    Does it display exactly as your first three examples? Silly question, but are both parent and child categories (direct descendants) assigned to the posts you are testing this with?

  5. I like screenshots
    Member
    Posted 1 year ago #

    OK I have 5 code examples here...
    http://pastebin.com/VsFfRVRS

    This is the screen shot of the 5 codes...
    http://snag.gy/Q9JVW.jpg

    This is the 5 custom terms (with hierarchy) the post has...

    parent: Towards Independence
    child: 013. Out in the community
    sub-child: A. Going out for a drink
    sub-sub-child#1: 1. Choose a place to go for a drink
    sub-sub-child#2: 2. Choose someone to go with or decode to go on your own


    As you can see...

    111 = no result
    222 = displayed ALL terms with hierarchy (not just the post's terms)
    333, 444, 555 = displayed the correct terms just not in hierarchy order :(

  6. I like screenshots
    Member
    Posted 1 year ago #

    The taxonomy name is "program"

  7. I like screenshots
    Member
    Posted 1 year ago #

    example 222 displays all the terms even if the post doesn't have ANY assigned to it... 222 essentially displays all the terms assigned to all posts

  8. keesiemeijer
    moderator
    Posted 1 year ago #

    Are you using this inside the loop? For testing, can you change this:

    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );

    to this:

    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    echo '<pre>';
    print_r($post_terms);
    echo '</pre>';
  9. sydcode
    Member
    Posted 1 year ago #

    G'day Pete, hope this helps.

    1. Style argument is set to "none", remove to show list.
    'title_li=&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids

    2. Need to restrict terms like in #1.

    3. get_the_term_list() can't indent because it just gets the links and builds a string.
    see wp-includes/category-template.php (line 1090)

    4. the_terms() is a wrapper for get_the_term_list(). same as #3.

    5. same as #3.

    Also, you may need to tweak the stylesheet because some themes don't indent lists.

  10. I like screenshots
    Member
    Posted 1 year ago #

    Thanks for that guys... OK I think i've sussed most of it out... I'm using the Genesis framework with the simple hooks plugin, something in this isn't allowing code#1 to display, however I tried a 'normal' theme and code #1 works fine , EXCEPT it doesn't show the parent term. Code #1 lo0ks the best so far. Any way to get the parent term to display?

  11. I like screenshots
    Member
    Posted 1 year ago #

    Disregard the "Any way to get the parent term to display?" comment... i forgot to check it :P

    Thanks for all your help with this... much appreciated

Topic Closed

This topic has been closed to new replies.

About this Topic