What would be the proper way to add a group by to the media library query? What I have tired so far is not working:
add_filter('posts_groupby ', 'limitMediaLibraryItems', 10, 2 );
function limitMediaLibraryItems($groupby) {
if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-admin/upload.php' ) !== false ) {
$groupby .= " guid";
}
return $groupby;
}
Updated: Maybe the correct approach is to use the ajax_query_attachments_args filter. How could this be made to work?
add_filter( 'ajax_query_attachments_args', 'hide_duplicate_guids', 10, 1 );
function hide_duplicate_guids( $query = array() ) {
$query['group by'] = 'guid';
return $query;
}
GROUP
are of very limited use in post queries. Also it's strange to seeguid
used as non–unique field?..