• Resolved Robin

    (@cinghaman)


    I have ACF fields to my listing CPT, and one of the fields have multi-select checkbox values as full time, part time, self-study
    I have in my excelsheet all these three values (full-time: no, part-time: no, self-study: yes and so on for all the elements)
    How can I map these values so a correct checkbox is checked when I do import

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hey @cinghaman

    If you’re using our ACF add-on, then you’ll need to put the slugs of the checkboxes ( separated by commas ) in the ACF field. Going based on your example string, a custom PHP function in the import could be used to return the values – here’s an example snippet:

    function my_get_checkboxes( $data ) {
    	$data = explode( ",", $data );
    	$return = array();
    	
    	if ( !empty( $data ) ) {
    		foreach( $data as $items ) {
    			$items = explode( ":", $items );
    			if ( trim( $items[1] ) == 'yes' ) {
    				$return[] = trim( $items[0] );
    			}
    		}
    	}
    	return ( empty( $return ) ) ? implode( ",", $data ) : implode( ",", $return );
    }

    If you’re not using the ACF add-on, then you can use our API to import the values: http://www.wpallimport.com/documentation/developers/action-reference/

    Thread Starter Robin

    (@cinghaman)

    Perfect, thanks that’s what i was looking for
    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Importing for checkbox values’ is closed to new replies.