It would be similar to https://www.wpallimport.com/documentation/code-snippets/#how-to-import-jetengine-relations
Import the comma-separated field to a temporary field key, such as _temp_rel_field
.
Add code similar to the below example All Import > Settings > Function Editor
<?php
/**
* Convert field containing comma-separated relationships IDs to a Pods relationship.
*
* @see https://www.wpallimport.com/documentation/code-snippets/#how-to-import-jetengine-relations
*/
add_action(
'pmxi_saved_post',
function( $id ) {
$temporary_field_key = '_temp_rel_field';
$real_field_key = 'rel_field';
$post_type = 'post';
// Convert comma-separated IDs to array of integers.
$temporary_field_value = get_post_meta( $id, $temporary_field_key, true );
$value_as_array = empty( $temporary_field_value )
? [] // Default if empty.
: array_map(
function( $related_id ) {
// Remove whitespace and assure the ID is an integer.
return intval( trim( $related_id ) );
},
explode( ',', $temporary_field_value ) // Comma-separated.
);
// Save the relationship field.
pods( $post_type, $id )->save(
[
// Key is the name of the field, configured above.
// Value is an array of IDs stored as integers.
$real_field_key => $value_as_array,
]
);
// Remove temporary data.
delete_post_meta( $id, $temporary_field_key );
},
10,
1
);
Above assumes IDs are imported literally in the import file.
If IDs have changed, looking up IDs according to another reference, such as comma-separated slugs, may be more appropriate.
e.g., Import file stores slugs, array_map()
looks up ID from slug, then returns array of IDs. Such an approach may be more appropriate for a post-import hook if the relationships are to the post type being imported.
If no post-import hook is available, one could also query all posts with the temporary field, then run manually after the import.