WP_REST_Server::READABLE, 'callback' => array( $this, 'get_all_items' ) ), ]); } public function get_all_items( $request ) { $args = array( 'numberposts' => 20, 'post_type' => [ 'artist', 'episode', 'event', 'exhibition', 'guide', 'object', 'publication', 'technique', 'short', 'post', 'page' ], 'meta_query' => [array( 'key' => 'is_sticky', 'value' => 'on', 'compare' => 'LIKE' )] ); return new WP_REST_Response( $this->prepare_all_items_for_response($args), 200 ); } public function prepare_all_items_for_response( $args ) { $collection = array(); // https://developer.wordpress.org/reference/functions/get_posts/ foreach( get_posts($args) as $item ) { $collection[$item->ID] = default_post_format( $item, true ); } wp_reset_postdata(); return $collection; } } ?>