Inventory_Presser_Plugin::change_order_by_for_odometer( string $orderby, object $query )

change_order_by_for_odometer


Description Description

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.


Top ↑

Parameters Parameters

$orderby

(string) (Required) The ORDER BY clause of a database query

$query

(object) (Required) An instance of the WP_Query class


Top ↑

Return Return

(string) The changed ORDER BY clause


Top ↑

Source Source

File: inventory-presser.php

	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
		 */
		return str_replace( 'wp_postmeta.meta_value+0', "REPLACE( wp_postmeta.meta_value, ',', '' )+0", $orderby );
	}