ありがとうございます。
教えていただいたソースそのままですと
ループの閉じ方でエラーになってしまったのですが
(他のソースと合わせたときの自分の記述がおかしかった可能性もあります)
下記のようにして無事に動作しました。
$terms_table = array(
'1' => 'term1',
'2' => 'term2',
);
$args = array(
'post_type' => 'test',
'taxonomy' => 'test_category',
'posts_per_page' => -1
);
foreach ( $terms_table as $key => $value ) {
if ( is_single( $key ) ) {
$args['term'] = $value;
$query = new WP_Query( $args );
if ( $query->have_posts() ):
while ( $query->have_posts() ): $query->the_post();
//内容省略
wp_reset_postdata();
endwhile; endif;
}
}
大変勉強になりました。
どうもありがとうございました。
@ishitaka さん
どうもありがとうございます。
お陰さまでうまくいきました。
本文があるものを優先にしたいので
$orderby = "trim({$wpdb->posts}.post_content) = '' ASC, {$wpdb->posts}.post_date DESC";
の箇所をDECSではなくASCにしました。