Below is a PHP function you can use in WP All Import to enable custom text mapping anywhere in your import. You would use it in your import field like this:
[my_map({field[1]})]
Where "{field[1]}" would be the correct field name from your file.
The PHP code for the function editor:
function my_map($value) {
$replacements = array(
// YOU CAN ADD OR MODIFY REPLACEMENTS BELOW USING THE SAME SYNTAX
'small' => 'S',
'medium' => 'M',
'large' => 'L',
);
return isset($replacements[$value]) ? $replacements[$value] : $value;
}
Note that the text replacements works on the entire string of text and not individual words. In the above example, "small" would become "S" but "It's a small world" would be unchanged.
Thanks for this @m-thomson! -really useful and much-appreciated snippet!
I was wondering how you would use this with ACF Repeater fields? I've tried all combinations I can think of, but I haven't been successful in mapping repeater fields yet.
Any ideas? Do you have ACF Pro and can you see what I mean? If not then I'll try and flesh out the challenge that I am dealing with some more...
I hope you can help and many thanks!