WP All Import在代码中实现的各种挂钩、操作和过滤器中有许多未记录的特性。进行此类映射的最简单方法是向pmxi_options_options
并添加自定义规则。在导入配置步骤中,这些规则将显示在自定义字段手风琴下。
<?php
add_filter( \'pmxi_options_options\', function( $options ) {
// Match the desired custom post type
if ( $options[\'custom_type\'] != \'product\' ) {
return $options;
}
// Configure the custom fields
$options[\'custom_name\'][\'custom_field_name\'] = \'_custom_field_name\';
$options[\'custom_value\'][\'custom_field_name\'] = \'{csv_column[1]}\';
$options[\'custom_mapping_rules\'][\'custom_field_name\'] = json_encode( [
\'value_from_csv\' => \'value_to_custom_field\',
\'en\' => \'English\',
] );
return $options;
} );