呼び出す側
$args = array(
'post_type' => 'glossary',
'key' => array('gloss_type','region'),
'value' => array('9851','9790')
);
$query = new Model36618($args);
Modelクラス
class Model36618 extends WP_Query
{
public function __construct($var)
{
//配列をオブジエクトに変換。
$par =(object)$var;
//クエリー
$args = array(
'post_type' => $par->post_type,
'meta_query' => array(
'relation' => 'AND',
array(
'key' => $par->key[0],
'value' => $par->value[0],
),
array(
'key' => $par->key[1],
'value' => $par->value[1],
)
)
);
$the_query = new WP_Query($args) ;
//ループ
if($the_query->have_posts()){
While($the_query->have_posts()){
$the_query->the_post();
//Viewの記述
$view_obj = new View36618($par2) ;
}
wp_reset_postdata();
}//endif
}
}
Viewクラス
class View36618
{
public function __construct($par2)
{
the_title() ;
echo "<br>\n" ;
}//endfunction
}//endclass