php - Wordpress Loop - Show posts from custom taxonomy terms in heirarchical order -


ok, here's i'm trying do:

i've got custom post type called drinks-menu, taxonomy called drinks-menu-categories, , page template called template-drinks-menu.php.

the taxonomy has bunch of terms heirarchical - wine, children white , red; beer, children pilsener, stout, etc...

i want use 1 loop display posts these terms in same order they're ordered in admin. here's code i've got far:

    <?php      $post_type = 'drinks-menu';      // taxonomies post type     $taxonomies = get_object_taxonomies( (object) array('post_type' => $post_type ) );      foreach( $taxonomies $taxonomy ) :           // gets every "category" (term) in taxonomy respective posts         $terms = get_terms( $taxonomy );          foreach( $terms $term ) :               echo '<h1>'.$term->name.'</h1>';             if ( $term->description !== '' ) {                  echo '<div class="page_summary">'. $term->description .'</div>';             }             echo '<br>';              $posts = new wp_query( "taxonomy=$taxonomy&term=$term->slug&posts_per_page=-1&orderby=id&order=desc" );              if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post();                  ?>                 <a href="<?php the_permalink(); ?> "><?php the_title(); ?></a>                 <?php                 if( get_field( "price" ) ): ?>                     <?php echo '<span">'; the_field( "price" ); echo ' | '; the_field( "abv" ); echo '</span>';?>                 <?php endif;                 echo '<em>'; the_excerpt(); echo '</em><br><br>';              endwhile; endif;          endforeach;      endforeach;      ?> 

this working bring posts terms onto page, not in order. can see tried taxonomy=$taxonomy&term=$term-slug&posts_per_page=-1&orderby=id&order=desc it's not working, shows in alphabetical order.

any wordpress gurus can point me in right direction? hope i've been clear issue. :-)

  1. posts ordered in admin page "menu_order";
  2. if u want order posts using query_posts (wp_query constructor) u should use value of variable "orderby" in upper case -> "id".

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -