Created
July 25, 2016 08:59
-
-
Save propertyhive/854f0dd428094e00b678b25a0b198b77 to your computer and use it in GitHub Desktop.
Amend Property Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'propertyhive_property_query', 'custom_field_property_filter' ); | |
function custom_field_property_filter( $q ){ | |
global $post; | |
if (is_post_type_archive( 'property' )) | |
{ | |
if ( isset($_GET['my_field']) && $_GET['my_field'] != '' ) // YOUR CRITERIA HERE | |
{ | |
$meta_query = $q->get( 'meta_query' ); | |
$meta_query[] = array( | |
'key' => 'my_field', | |
'value' => $_GET['my_field'], | |
'compare' => '=' | |
); | |
$q->set( 'meta_query', $meta_query ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment