Created
April 20, 2016 21:15
-
-
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)
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_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