Inventory_Presser_Plugin::change_order_by_for_odometer( string $orderby, object $query )
Removes commas from the meta value used in the ORDER BY of the query so that odometer values can be sorted as numbers instead of strings.
Contents
Parameters Parameters
- $orderby
-
(string) (Required) The ORDER BY clause of a database query.
- $query
-
(object) (Required) An instance of the WP_Query class.
Return Return
(string) The changed ORDER BY clause
Source Source
File: inventory-presser.php
public function change_order_by_for_odometer( $orderby, $query ) { /** * Changes * ORDER BY wp_postmeta.meta_value+0 * to * ORDER BY REPLACE( wp_postmeta.meta_value, ',', '' )+0 */ global $wpdb; return str_replace( "$wpdb->postmeta.meta_value+0", "REPLACE( $wpdb->postmeta.meta_value, ',', '' )+0", $orderby ); }
Expand full source code Collapse full source code View on Github