$es_id]; $group = $existing; $es_cats = wp_get_post_categories($es_id); foreach (['en', 'fr', 'it', 'pt'] as $L) { if (!empty($existing[$L])) { $group[$L] = $existing[$L]; continue; } if (empty($row['langs'][$L])) continue; $id = wp_insert_post([ 'post_title' => $es->post_title, // referencia bíblica (igual en todos) 'post_content' => $row['langs'][$L], 'post_status' => $status, 'post_type' => 'post', 'comment_status' => 'closed', ], true); if (is_wp_error($id)) continue; pll_set_post_language($id, $L); $cats = []; foreach ($es_cats as $c) { $t = pll_get_term($c, $L); if ($t) $cats[] = $t; } if ($cats) wp_set_post_categories($id, $cats); $group[$L] = $id; $created++; } if (function_exists('pll_save_post_translations')) pll_save_post_translations($group); $posts_done++; } echo "posts ES procesados: $posts_done | traducciones creadas: $created | status=$status | skip=$skipped\n";