Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Mark Berg

Sorting by a numeric float doesn’t work

Hey,
I am using ACF.
I have a numeric number field which can be float as well
if I sort by this field the sorting is wrong.
This is a MySql ordering issue the sorting of a number should be casted.
Please fix this asap as this is a deal breaker for me.

2 weeks, 1 day ago
Stefan
Developer

Thanks for your feedback. I agree that our plugin should have a feature to support decimals for sorting. At this moment we cast all values to SIGNED in MySQL but we can add an option to cast to DECIMAL as well. I’ve created a ticket for this so that we can support floating data types for our sorting feature. We’re currently thinking about giving the option to change the datatype for a custom field with a hook, but we’re not sure if this will be the final solution.

2 weeks, 1 day ago
Mark Berg

Hi, when will this issue be addressed?

1 week, 2 days ago
Stefan
Developer

The latest version of Admin Columns Pro contains a new hook to change the behavior for the custom field column.

https://github.com/codepress/admin-columns-hooks/blob/master/acp-sorting-custom_field-numeric_type.php

So in your case, you might want to change the ACF column to the Custom Field column and use the hook to set the data type to decimal. To enable decimals for all numeric fields, the following snippet will do the trick.

add_filter( 'acp/sorting/custom_field/numeric_type', function(){
	return ACP\Sorting\Type\DataType::DECIMAL;
} );

We have to decide if we’re going to support this by default for the ACF numeric field, but using the custom field column is a working alternative for now.

1 week, 1 day ago
Mark Berg

Hey,
I’ve applied the filter logic and changed the fields to custom field instead of the advanced custom field
It still doesn’t work
Screenshot

1 day, 12 hours ago

You must be logged in to reply to this topic.