WordPress.org

Ready to get started?Download WordPress

Forums

Order by not working with wp_get_post_terms (1 post)

  1. w1cky
    Member
    Posted 1 year ago #

    I'm trying to display the terms for a given taxonomy (disciplines).

    I want the terms to display without links, and in alphabetical order. Everything works correctly, except for the ordering. No matter what I try I cannot get the list to order alphabetically by name.

    This is the code

    <?php 
    
    $args = array(
    'orderby' => 'name',
    'order' => 'ASC'
    );
    
    $disciplines = wp_get_post_terms($post->ID, 'disciplines', $args);
    
    echo '<ul>';
    foreach($disciplines as $discipline){
      echo '<li>' . $discipline->name . '</li>';
    }
    echo '</ul>';
    
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic