WP_Queryの拡張①Ratnayake氏の方法

呼び出す側

$the_query = new Model37188();
//ループ
if($the_query->have_posts()){
	While($the_query->have_posts()){
		$the_query->the_post();
		//Viewの記述	
		$view_obj = new View37188($par2) ;			
	}
	wp_reset_postdata();
}//endif

Modelクラス

class Model37188 extends WP_Query
{
	public function __construct( $args = array() )
	{
//クエリー	
		$args = wp_parse_args( $args, array(
			'post_type' => 'glossary',
			'meta_query' => array(
			'relation' => 'AND',
				array(
					'key' => 'gloss_type',
					'value' => '9851',
				),
				array(
					'key' => 'region',
					'value' => '9790',
				)
			)
		)
		);
		parent::__construct($args) ;
		
	}
}

Viewクラス

class View37188
{
	public function __construct($par2)
	{
		the_title() ;
		echo "<br>\n" ;	
	}//endfunction
}//endclass