This is for online scientific journal. I have posts attached to categories. Those posts are also attached to custom taxonomy called
First I need to retrieve all the posts that are attached to specific custom taxonomy term. Then I need to list the posts ordering them by their category names.
This is the actual page I’m working on. Please, visit to get a better idea: http://journal.fledu.uz/en/journal/1-15-2017/
I’m thinking of prefixing all the category names so that I can order them by their names like this:
01 Some category name
02 Another category name
03 Category name
04 And so on
Here’s my query:
$term = get_term_by( 'slug', get_query_var('term'), get_query_var('taxonomy') ); $term_date = get_term_meta($term->term_id, 'journal_date', true); $journals = get_terms('journals'); $jurloop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => -1, 'order' => 'ASC', 'tax_query' => array( array( 'taxonomy' => 'journals', 'field' => 'id', 'terms' => $term, // Where term_id of Term 1 is "1". 'include_children' => true ) ) ) );
The the loop:
<?php if ($jurloop->have_posts()) : ?> <?php while ( $jurloop->have_posts() ) : $jurloop->the_post(); ?> my stuff <?php endwhile; ?> <?php endif; ?>
How can I order the posts by the names of the categories that they are attached to?
Read more here: How to order posts by their category names?