たとえば
?area[]=tokyo&area[]=chiga&width[]=2ldk&width[]=2DK ・・・みたいな「AでありBでありCであり」みたいな検索を実装するときのPHP側のクエリの取り方。
array_pushでクエリ用のarrayに突っ込んでやれば動く。
たとえば
?area[]=tokyo&area[]=chiga&width[]=2ldk&width[]=2DK ・・・みたいな「AでありBでありCであり」みたいな検索を実装するときのPHP側のクエリの取り方。
array_pushでクエリ用のarrayに突っ込んでやれば動く。
<?php//GETとってクエリ化if($_GET){$qarr = array('numberposts' => 10,'post_status' => 'publish','post_type' => 'post','tax_query' => array('relation' => 'AND',array('taxonomy' => 'category','terms' => array('1'),'operator'=>'IN')));foreach( $_GET as $key => $value ) {if($key == '_'){} else {array_push($qarr["tax_query"],array('taxonomy' => $key,'field' => 'slug','terms' => $value,'operator'=>'AND'));}}} else {$qarr = array('numberposts' => 10,'post_status' => 'publish','post_type' => 'post','tax_query' => array('relation' => 'AND',array('taxonomy' => 'category','terms' => array('1'),'operator'=>'IN')));}?><?php $myposts = get_posts($qarr); ?>