Sort search result by custom meta data
-
Hi,
we would like to sort the search results by custom meta data. We added a custom checkbox. The value is properly stored in the database. We can echo the value in the listing template. Say, the meta key is “wpsl_my_checkbox”. If the checkbox is checked, the meta value “1” is stored in the database. According to https://wpstorelocator.co/document/change-search-results-order/ we can change the sort order. However, if we change line 8 to
$custom_sort[$key] = $row['wpsl_my_checkbox'];
nothing happens. If we use, for example, “id”, everything works fine. Is it possible to sort by custom meta data? How would we change the code snippet?Thank you!
The topic ‘Sort search result by custom meta data’ is closed to new replies.