Last active
March 5, 2019 09:07
-
-
Save msaari/1176b1f39b893d90f2729b3968e601ec to your computer and use it in GitHub Desktop.
Filters out matches outside custom fields
This file contains hidden or 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
<?php | |
add_filter( 'relevanssi_match', 'rlv_customfield_match_filter', 10 ); | |
function rlv_customfield_match_filter( $match ) { | |
global $wp_query; | |
if ( 'listing' === $wp_query->query_vars['post_type'] ) { | |
// This is a listing search. | |
if ( $match->customfield < 1 ) { | |
// No custom fields were hit, set weight to zero. | |
$match->weight = 0; | |
} | |
} | |
return $match; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment