Forums

[resolved] Order terms by term/subterm with wp_get_post_terms (2 posts)

  1. joemastro
    Member
    Posted 6 months ago #

    Sigh....

    I can't find information on how to order terms using wp_get_post_terms. I need it ordered by category/sub-category, and the function wants to order it by name.

    get_term_list will not work because of how I need to display it (custom hyperlinks).

    Thanks!

  2. joemastro
    Member
    Posted 6 months ago #

    Resolved. Need to use wp_get_object_terms

    <?
    $args=array('orderby'=>'parent');
    $product_terms = wp_get_object_terms(get_the_ID(), 'ls-itin',$args);
    if(!empty($product_terms)){
    echo "effing terms here";
      if(!is_wp_error( $product_terms )){
        echo '
    <ul>';
        foreach($product_terms as $term){
          echo '
    <li><a>slug, 'ls-itin').'">'.$term->name.'</a></li>
    ';
        }
        echo '</ul>
    ';
      }else echo"bologna";
    }
    ?>

Reply

You must log in to post.

About this Topic