Admin column with callback is not sortable
iamcanadian1973 opened this issue · 1 comments
iamcanadian1973 commented
Trying to set sortable columns for ACF fields. Maybe I'm misunderstanding what is possible?
'zip' => array(
'title' => 'Zip Code',
'sortable' => true,
'function' => function() {
$google_map = get_field( 'google_map' );
if( ! empty( $google_map['postal_code'] ) ) {
echo $google_map['postal_code'];
}
},
)
johnbillion commented
WordPress needs a database field name to sort by in order to fetch the results in the correct order. As you're storing the postal code within the Google map field as an associative array there's no way for WordPress to sort by that value.
If you're able to restructure your code so that the postal code is stored in its own meta field instead of within an array in the Google map field then you can make it sortable by treating it as a regular meta field column type.