I'm trying to sort my posts like so:
CATEGORY 1
- post title
- post title
CATEGORY 2
- post title
- post title
I have no problem achieving this with a custom query:
<?php
$args = array(
'orderby' => 'name',
'hide_emppty' => 1,
'hierarchical' => false,
'taxonomy' => 'course_category'
);
$categories = get_categories($args);
foreach ($categories as $category) : ?>
<h3><?php echo $category->name; ?></h3>
<?php $courses = new WP_Query( "post_type=courses&posts_per_page=-1&course_term=term-fall&course_category=" . $category->slug); ?>
<?php if ( $courses->have_posts() ) : while ( $courses->have_posts() ) : $courses->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; endif; ?>
<?php endforeach; ?>
However, what I need to do is sort posts that come from a plugin-generated query (I have no (?) control over it) - so this needs to happen inside a normal if(have_posts()) : while (have_posts())
loop.
Is this even possible? The posts from this query are all of correct post type and course_term custom taxonomy, just need to get sorted by course_category taxonomy like above.
Thanks in advance for your help!