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 to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Post taxonomy issue’ is closed to new replies.