Title: Post taxonomy issue
Last modified: May 23, 2019

---

# Post taxonomy issue

 *  Resolved [mlasuzzo](https://wordpress.org/support/users/mlasuzzo/)
 * (@mlasuzzo)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/post-taxonomy-issue/)
 * Hello all,
 * I want my page to sort my features ($terms) to be listed in alphabetical order.
   Currently, it seems that they are in the order that they were added to the site.
   I have tried using a plugin, Post Types Order by Nsp Code, but it didn’t work.
   What should I add to my code to give the desired effect?
 *     ```
               <div class="page-container">
   
                   <div class="features-section__head">
                       <h2 class="features-section__title"><?php the_field('features_title', 'option'); ?></h2>
                       <span class="features-section__selected-cat js-phone-cat"></span>
                       <?php
                       $taxonomy = 'features_categories';
                       $terms = get_terms($taxonomy); // Get all terms of a taxonomy
   
                       if ( $terms && !is_wp_error( $terms ) ) :
                           ?>
                           <ul class="features-section__categories js-phone-cat-list">
                               <?php foreach ( $terms as $term ) { ?>
                                   <li class="features-section__item js-features-cats" data-tab="<?php echo $term->term_id ?>"><?php echo $term->name; ?></li>
                               <?php } ?>
                           </ul>
                       <?php endif;?>
                   </div>
   
                   <div class="features-section__posts">
                       <?php
                       $taxonomy = 'features_categories';
                       $terms = get_terms($taxonomy); // Get all terms of a taxonomy
                       if ($terms && !is_wp_error($terms)) :
                           foreach ($terms as $term) { ?>
                               <ul class="features-posts js-features-posts" data-cat="<?php echo $term->term_id ?>">
                                   <?php
                                   $loop = new WP_Query(
                                       array('post_type' => 'features',
                                           'tax_query' => array(
                                               array(
                                                   'taxonomy' => 'features_categories',
                                                   'field' => 'id',
                                                   'terms' => $term->term_id,
                                               )
                                           ),
                                           'posts_per_page' => -1,
                                           'suppress_filters' => false
                                       ));
                                   if ($loop->have_posts()):
                                       while ($loop->have_posts()) : $loop->the_post(); ?>
                                           <li class="features-posts__item ">
                                               <a class="features-posts__link" href="<?php echo the_permalink(); ?>"><?php echo the_title(); ?></a>
                                           </li>
                                       <?php endwhile; ?>
                                       <?php wp_reset_postdata();
                                   endif;
                                   ?>
                               </ul>
                           <?php } endif; ?>
                   </div>
   
               </div>
       ```
   
 * Thank you in advance!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fpost-taxonomy-issue%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [mlasuzzo](https://wordpress.org/support/users/mlasuzzo/)
 * (@mlasuzzo)
 * [6 years, 12 months ago](https://wordpress.org/support/topic/post-taxonomy-issue/#post-11565981)
 * I read a bit more about posts and added a few params to the code:
 *     ```
                                   $loop = new WP_Query(
                                       array('post_type' => 'features',
                                           'tax_query' => array(
                                               array(
                                                   'taxonomy' => 'features_categories',
                                                   'field' => 'id',
                                                   'terms' => $term->term_id,
                                               )
                                           ),
                                           'posts_per_page' => -1,
                                           'suppress_filters' => false,
       			            'orderby' => 'title',
          				    'order'   => 'ASC',
       ));
       ```
   
    -  This reply was modified 6 years, 12 months ago by [mlasuzzo](https://wordpress.org/support/users/mlasuzzo/).

Viewing 1 replies (of 1 total)

The topic ‘Post taxonomy issue’ is closed to new replies.

## Tags

 * [dev](https://wordpress.org/support/topic-tag/dev/)
 * [post order](https://wordpress.org/support/topic-tag/post-order/)
 * [taxonomies](https://wordpress.org/support/topic-tag/taxonomies/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 1 participant
 * Last reply from: [mlasuzzo](https://wordpress.org/support/users/mlasuzzo/)
 * Last activity: [6 years, 12 months ago](https://wordpress.org/support/topic/post-taxonomy-issue/#post-11565981)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
