Title Ascending order only for category pages
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.
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.
Thanks in advance.
You can use this hook:
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
}
Thank you, we will try this way.
You must be logged in to reply to this topic.