$id, 'post_type' => 'acf-field', 'numberposts' => -1 ); $posts = get_posts($args); if (is_array($posts) && count($posts) > 0) { foreach($posts as $post) { wp_delete_post($post->ID, true); } } } } /** * Filter: Update clloned field names to translated version * * @param $field * * @return updated field */ public function duplicate_clone_field($field) { $parent_language = apply_filters('wpml_post_language_details', null, $field['parent']); foreach ($field['clone'] as $id => $key_post_name) { if (strpos($key_post_name, 'group_') === 0) { $original_id = $this->get_post_id_by_name($key_post_name); $translated_id = apply_filters('wpml_object_id', $original_id, 'acf-field-group', false, $parent_language['language_code']); if ($translated_id) { $post = get_post($translated_id); if (isset($post->post_name)) { $field['clone'][$id] = $post->post_name; } } } } return $field; } private function get_post_id_by_name($post_name, $output = OBJECT) { global $wpdb; $post_id = null; $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_name = %s", $post_name )); return $post_id; } }