From 771c712e647008e76c6935b3cea0bf1637104daf Mon Sep 17 00:00:00 2001 From: wordpress-peytz <79707905+wordpress-peytz@users.noreply.github.com> Date: Thu, 9 Mar 2023 10:55:36 +0100 Subject: [PATCH] Association Field options order by Add filter to control order of Association Field options. --- core/Field/Association_Field.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/Field/Association_Field.php b/core/Field/Association_Field.php index d46331b3..362ef8d8 100644 --- a/core/Field/Association_Field.php +++ b/core/Field/Association_Field.php @@ -221,7 +221,10 @@ public function get_options( $args = array() ) { $per_page = $this->get_items_per_page(); $offset = ($args['page'] - 1) * $per_page; - $sql_queries .= " ORDER BY `title` ASC LIMIT {$per_page} OFFSET {$offset}"; + $order_by = '`title` ASC'; + $order_by = apply_filters('carbon_fields_association_field_options_order', $order_by, $this->get_base_name(), $args ); + + $sql_queries .= " ORDER BY {$order_by} LIMIT {$per_page} OFFSET {$offset}"; $results = $wpdb->get_results( $sql_queries );