• Resolved dorgs04

    (@dorgs04)


    Hi all,

    Just reaching out to see if anyone has thoughts or solutions for the following:

    I am currently trying to import a csv with multiple ‘Select’ Advance Custom Fields, some of these selections have html links which aren’t being pulled through or selected within the individual post when imported. I have tried using the XPath, and individually mapping, but no joy.

    Example Select Field:

    a href=”https://localhost:8888/testsite/”>Test A : Test A
    a href=”https://localhost:8888/testsite/”>Test B : Test B
    a href=”https://localhost:8888/testsite/”>Test C : Test C

    Is there a better way todo this? Any help much appreciated.

    Many thanks

    • This topic was modified 5 years, 2 months ago by dorgs04.
    • This topic was modified 5 years, 2 months ago by dorgs04.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @dorgs04

    If your custom field set up looks like this in ACF: https://d.pr/i/aIvRJK, you’ll have to import the values on the left in WP All Import. So, for example, to select “Test C”, you’d import this under “Set with XPath”:

    <a href="https://localhost:8888/testsite/">Test</a> C

    If that doesn’t work for you, please replicate the problem at https://wpallimport.com/debug and open a ticket at https://www.wpallimport.com/support/ with the details.

    Thread Starter dorgs04

    (@dorgs04)

    Thanks for the quick reply.

    I’m still not sure how to apply the different values to the XPath field. If you can explain alittle more, I’m sure I can use this.

    I did manage to achieve my required results partly using the Custom Fields, Field Options, Mapping. Only problem, the links or html aren’t saved to the template under ‘Translated To’ the template to use again.

    Is there a way to get the ‘Translated To’ field to save the html im adding?
    But Im not sure if this is the best way to proceed.

    Thanks again for your help.

    Thanks again for all your

    Plugin Author WP All Import

    (@wpallimport)

    Hi @dorgs04

    I’m still not sure how to apply the different values to the XPath field.

    You’d import a comma delimited list of the values in the “Set with XPath” option for your field, inside the ACF Add-On section: https://d.pr/i/RmlRkf.

    I did manage to achieve my required results partly using the Custom Fields, Field Options, Mapping.

    Importing via the Custom Fields section wouldn’t work for ACF fields. If you need to map the HTML values, you should use a custom PHP function to do it instead: https://www.wpallimport.com/documentation/developers/execute-php/. Example snippet:

    function my_translate_data( $data ) {
        $map = array(
            'Translate this'            => 'To this',
            'Add as many mapping rules' => 'As needed',
            'In this'                   => 'Array'
        );
        return ( array_key_exists( $data, $map ) ) ? $map[ $data ] : $data;
    }
    Thread Starter dorgs04

    (@dorgs04)

    Many thanks

    The function array worked perfectly.
    Is there a way to use this to select/output multiple values?

    Many thanks

    Plugin Author WP All Import

    (@wpallimport)

    Hi @dorgs04

    Is there a way to use this to select/output multiple values?

    Do you mean that you need to apply the same mapping rules to multiple elements? If so, you could adjust the function like this:

    function my_translate_data( $data = array() ) {
        $map = array(
            'Red Post' => 'Awesome Post',
            'Green Post' => 'Crazy Post',
            'Blue Post' => 'Insane Post'
        );
    	
    	$data = implode( ",", $data );
    	return str_ireplace( array_keys( $map ), $map, $data );
    }

    Then pass your elements to it as an array:

    [my_translate_data(array({element1},{element2[1]},{element3[1]}))]

    Plugin Author WP All Import

    (@wpallimport)

    Hi @dorgs04

    I’m marking this as resolved since we’ve not heard back. Let us know if you still have questions regarding this issue.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Import Custom Field Values’ is closed to new replies.