Hello Team,
We have a requirement like to add a sort of ‘title ascending’ but it should not show on search page only for category pages which we are showing data using solr. Is there any action we can show particular sort only for category pages.
use wpsolr\core\classes\WPSOLR_Events;
add_filter( WPSOLR_Events::WPSOLR_FILTER_SORT_FIELDS, 'wpsolr_filter_sort_fields', 10, 1 );
public function wpsolr_filter_sort_fields($default_sort_fields) {
// If current page is a category, then modify default_sort_fields
(...)
return $default_sort_fields; // array of field names
}