I wish to filter posts regarding custom fields put into a publish.Now I added two custom fields city,zip for every publish. I wish to filter posts regarding both of these fields. Just how can write a custom query for this.
Within the where clause I authored meta_key='City' and meta_value='myval'. It really works and returns the publish with custom area City and cost 'myval'. But I wish to check both City and Zip.How do i do this.
In my opinion you utilize meta_query with this - just dealing with a classic project now, appears like meta_query may take in a wide array of filters:
array( 'posts_per_page' => 10, 'meta_query' => array( array('key'=>'key', 'value'=>'value', 'compare'=>'='), array('key'=>'key2', 'value'=>'value2', 'compare'=>'=') ) )
Clearly completely untested IRL, but appears like it really works from the finish.