Sourceパターン(Post→Post) meta_query

class code37167
{
	public function __construct()
	{
		$args = array(
			'model' => '37167',
			'view' => '37167',
			'post_type' => 'post',
			'field' => array('ref'),//参考文献
			'field_value' => array('18661'),//第八章 月島の商業
		);
		$user = new Controller37167($args) ;
	}//endfunction
}//endclass

class Controller37167
{	
	
	public function __construct($args)
	{
//////配列をオブジェクトに変換
		$par =(object)$args;
//////Modelメソッドの呼び出し
			$model_name = 'Model'.$par->model ;	
			$model_obj = new $model_name($par) ;
	}//endfunction
}//endclass

class Model37167
{
	public function __construct($par)
	{
		$args = array(		
			'post_type' => $par->post_type,
			'meta_query' => array(
			'relation' => 'OR',
				array(
					'key' => $par->field[0],
					'value' => $par->field_value[0],
				)
			)
		);
		$the_query = new WP_Query($args) ;

//ループ~表示処理(Viewクラス)の呼び出し。
		if($the_query->have_posts()){
			While($the_query->have_posts()){
				$the_query->the_post();
					$view_name = 'View'.$par->view ;
					$view_obj = new $view_name($par) ;
			}
		}//endif
	}//endfunction

}//endclass

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

参考文献

参考記事