public static function add_all_citations($citations) { $types = CandelaCitation::postTypes(); foreach ($types as $type) { $posts = get_posts(array('post_type' => $type, 'post_status' => 'any', 'posts_per_page' => '-1')); foreach ($posts as $post) { // Get existing citations and append new ones. $existing = CandelaCitation::get_citations($post->ID); if (!empty($existing)) { $new = array_merge($existing, $citations); } else { $new = $citations; } update_post_meta($post->ID, CANDELA_CITATION_FIELD, json_encode($new)); } } }