I have a custom post type called as books
with taxonomy named as genre
. Inside the genre
there are a number of terms such as horror
, romance,
comedy`, etc.
I want to display them in the archive page, grouped by each terms. So I use Chip Bennet's fantastic code.
However, I have problem with the sorting.
The code sorts the terms according to its alphabetical names, and the posts according to the recentness. So it appears like this:
- Comedy
- Newest book
- Not so new book
- Old book
- Horror
- etc the same: newest - not new - old
- Romance
- Sci-fi
Meanwhile, I need it to be sorted differently. I want to sort the terms according to the tag_ID, and the book list according to its alphabetical name. So it should look like this:
- Sci-fi
(tag_ID number 1)
- A
- B
- C
- etc
- Romance
(tag_ID number 2)
- Comedy
(tag_ID number 3)
- Horror
(tag_ID number 4)
I tried to mess with the query, so it looks like this
$member_group_query = new WP_Query( array(
'post_type' => 'member',
'orderby ' => 'name', // sort the books alphabetically
'tax_query' => array(
array(
'taxonomy' => 'member_group',
'field' => 'slug',
'terms' => array( $member_group_term->slug ),
'orderby ' => 'ID', // sort the genre according to its ID
'operator' => 'IN'
)
)
) );
But nothing changes. I checked Wordpress Codex on WP_Query
to make sure but still no avail. Any help?