Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Sort Column Query.
*
* @since 1.1.0
*
* @param object $query WP_Query object.
*/
public function sort_column_query( $query ) {
if ( is_admin() && 'shared_counts' === $query->get( 'orderby' ) ) {
$meta_query = array(
'relation' => 'OR',
array(
'key' => 'shared_counts_total',
'type' => 'NUMERIC',
'compare' => 'EXISTS',
),
array(
'key' => 'shared_counts_total',
'type' => 'NUMERIC',
'compare' => 'NOT EXISTS',
)
);
$query->set( 'orderby', 'meta_value_num date' );
$query->set( 'meta_query', $meta_query );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.