filter empty objects from results before loop

This commit is contained in:
Mike Jolley 2019-08-01 16:52:52 +01:00 committed by Claudio Sanches
parent 59a3bc7525
commit 7d8f8163b6
1 changed files with 1 additions and 1 deletions

View File

@ -337,7 +337,7 @@ abstract class WC_REST_CRUD_Controller extends WC_REST_Posts_Controller {
}
return array(
'objects' => array_map( array( $this, 'get_object' ), $result ),
'objects' => array_filter( array_map( array( $this, 'get_object' ), $result ) ),
'total' => (int) $total_posts,
'pages' => (int) ceil( $total_posts / (int) $query->query_vars['posts_per_page'] ),
);