Skip to content

Instantly share code, notes, and snippets.

@hauge75
Created April 20, 2016 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hauge75/4b81efaf301b27d5ad2c9876739ed9e4 to your computer and use it in GitHub Desktop.
Save hauge75/4b81efaf301b27d5ad2c9876739ed9e4 to your computer and use it in GitHub Desktop.
Give double weight to current and future events in relevanssi search (Relevanssi & Events Manager)
add_filter('relevanssi_match', 'date_weights');
function date_weights($match) {
$EM_Event = em_get_event($match->doc, 'post_id');
$enddate = $EM_Event->event_end_date;
$yesterday = time() - 24*60*60;;
if (strtotime($enddate) > $yesterday) {
$match->weight = $match->weight * 2;
}
else {
$match->weight = $match->weight / 2;
}
return $match;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment