Site icon Hip-Hop Website Design and Development

Can not seem to filter wp_query by present class ID

I am querying a customized put up sort (“donor”) and want to listing them grouped by class (a customized taxonomy for this put up sort), with the class title then all posts for that class.

After a lot analysis, I’ve obtained this (in my customized put up sort’s archive template, archive-donor.php):

world $paged;
world $query_args;


$category_args = array(
'taxonomy' => 'donor_taxonomy',
'orderby' => 'title',
'mum or dad' => 0
  );
$classes = get_categories( $category_args );
foreach ( $classes as $class ) {

echo '<h3><a href="' . get_category_link( $category->term_id ) . '">' . $category->title . '</a></h3>';  

echo 'ID is: ' . $category->term_id . '. ';

$post_args = array(
    'cat' => $category->term_id,
    'post_type' => 'donor',
    'orderby'       => 'post_date',
    'posts_per_page'=> '-1', // overrides posts per web page in theme settings

);

$loop = new WP_Query( $post_args );
if( $loop->have_posts() ) {

 [query stuff here that works fine when I do NOT try to specify the category in my query args]
} 

wp_reset_postdata();    
}

Though I can echo the ID quantity with this line…

echo 'ID is: ' . $category->term_id . '. ';

…If I embrace the next with my $post_args, which makes use of the identical code to extract the ID, it says no posts had been discovered:

'cat' => $category->term_id

If I depart that line out, I get all posts no matter class, listed after every class title. If I embrace it, I get “no posts discovered” after every title. The titles themselves show accurately so as.

I have to be doing one thing mistaken however cannot for the lifetime of me work out what. Hope somebody might help! 8^)