/** * Apply all postmeta and terms to an array of posts * @param arr $posts array of post objects * @return arr array of posts, with ID's as keys, and all postmeta and terms applied */ static function apply_postmeta_and_terms_to_posts($posts) { // make sure the first post has a post type if (empty($posts[0]->post_type)) { return $posts; } // build array of id's $post_id_arr = array(); foreach ($posts as $post) { $post_id_arr[] = $post->ID; } // get postmeta for all posts $postmeta = Kanban_Post::get_postmeta_for_posts($post_id_arr, $posts[0]->post_type); // get terms for all posts $terms = Kanban_Terms::get_terms_for_posts($post_id_arr, $posts[0]->post_type); // apply post meta and terms to projects foreach ($posts as $post) { if (isset($postmeta[$post->ID])) { $post->postmeta = $postmeta[$post->ID]; } if (isset($terms[$post->ID])) { $post->terms = $terms[$post->ID]; } } // put get array with post id's as keys return Kanban_Utils::build_array_with_id_keys($posts); }