-
Notifications
You must be signed in to change notification settings - Fork 64
How do I implement sorting?
Paris Holley edited this page Jun 18, 2015
·
6 revisions
Here is an example of how you can implement sorting in your theme/search:
add_filter('elasticsearch_searcher_query', function($query){
if(!isset($_GET['sort']) || $_GET['sort'] == 'date'){
$query->addSort(array('post_date' => array('order' => 'desc')));
}else{
$query->addSort(array('_score' => array('order' => 'desc')));
}
});