呼び出す側
$args = array(
'tax' => 'region',
'term' => '9789',
);
set_query_var( 'val', $args) ;
get_template_part( 'template-parts/sample/content', 'sample' );
呼び出される側
<?php
//引数を受け取り
$var = get_query_var('val');
$par =(object)$var;
//サブクエリー
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => $par->tax,
'field' => 'term_id',
'terms' => $par->term,
)
)
);
$the_query = new WP_Query($args) ;
//サブループ
if($the_query->have_posts()){
While($the_query->have_posts()){
$the_query->the_post();
//表示
the_title() ;
echo "<br>\n" ;
}
}//endif