diff --git a/includes/rest-api/Version1/class-listings-controller.php b/includes/rest-api/Version1/class-listings-controller.php index 145930186..55519e55c 100644 --- a/includes/rest-api/Version1/class-listings-controller.php +++ b/includes/rest-api/Version1/class-listings-controller.php @@ -1489,14 +1489,29 @@ public function get_collection_params() { } protected function get_orderby_possibles() { - return array( - 'id' => 'ID', - 'include' => 'include', - 'title' => 'title', - 'date' => 'date', - // 'rating' => 'rating', - 'popular' => 'popular', - 'price' => 'price', + /** + * Filter the available "orderby" options used in the listings API schema and controller. + * + * This hook allows developers to modify or extend the enum values that define the orderby options + * for listing queries in the Directorist REST API. These options control how listings are sorted + * when fetched via API (e.g., by date, title, rating, etc.). + * + * @param array $orderby_options Array of allowed orderby values. + * + * @return array Modified list of orderby options. + */ + return apply_filter( + 'directorist_listings_controller_orderby_options', + array( + 'id' => 'ID', + 'include' => 'include', + 'title' => 'title', + 'date' => 'date', + // 'rating' => 'rating', + 'popular' => 'popular', + 'price' => 'price', + 'rand' => 'rand', + ) ); }