Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save propertyhive/854f0dd428094e00b678b25a0b198b77 to your computer and use it in GitHub Desktop.
Save propertyhive/854f0dd428094e00b678b25a0b198b77 to your computer and use it in GitHub Desktop.
Amend Property Query
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