advanced custom fields - help with really simple csv importer

( sorry for the title, but i dont know how to explain this as a title ^^ ).I'm using really simple csv importer to

( sorry for the title, but i dont know how to explain this as a title ^^ ).

I'm using really simple csv importer to bulk import data in my site, using Advanced custom fields.

So i need to import some data as serialized data. So i used the hook "really_simple_csv_importer_save_meta_filter" as show in docs.

But i have an issue, the hook just explain how to filter serialized data, but not how to keep normal data. So it works well with my 2 serialized columns, and delete all the other columns.

how can i custom my hooks to keep other columns active ?

my columns :

post_type post_title contact_city seo_h1 marche_tel rank_math_title marche_periode marche_h_debut marche_h_fin marche_www marche_latitude marche_longitude marche_maps marche_dpt type_un type_deux type_trois jour_un jour_deux jour_trois jour_quatre jour_cinq jour_six jour_sept

my hook :

function really_simple_csv_importer_save_meta_filter( $meta, $post, $is_update ) {
    $meta_array = array();

    $metas = [
        'marche_jours' => ['jour_un', 'jour_deux', 'jour_trois', 'jour_quatre', 'jour_cinq', 'jour_six', 'jour_sept'],
        'marche_type' => ['type_un', 'type_deux', 'type_trois'],
    ];

    foreach ($metas as $metaKey => $metaFields) {
        foreach ($metaFields as $field) {
            if (isset($meta[$field])) {
                $meta_array[$metaKey][] = $meta[$field];
            }
        }
    }

    return $meta_array;
}
add_filter( 'really_simple_csv_importer_save_meta', 'really_simple_csv_importer_save_meta_filter', 10, 3 );

( sorry for the title, but i dont know how to explain this as a title ^^ ).

I'm using really simple csv importer to bulk import data in my site, using Advanced custom fields.

So i need to import some data as serialized data. So i used the hook "really_simple_csv_importer_save_meta_filter" as show in docs.

But i have an issue, the hook just explain how to filter serialized data, but not how to keep normal data. So it works well with my 2 serialized columns, and delete all the other columns.

how can i custom my hooks to keep other columns active ?

my columns :

post_type post_title contact_city seo_h1 marche_tel rank_math_title marche_periode marche_h_debut marche_h_fin marche_www marche_latitude marche_longitude marche_maps marche_dpt type_un type_deux type_trois jour_un jour_deux jour_trois jour_quatre jour_cinq jour_six jour_sept

my hook :

function really_simple_csv_importer_save_meta_filter( $meta, $post, $is_update ) {
    $meta_array = array();

    $metas = [
        'marche_jours' => ['jour_un', 'jour_deux', 'jour_trois', 'jour_quatre', 'jour_cinq', 'jour_six', 'jour_sept'],
        'marche_type' => ['type_un', 'type_deux', 'type_trois'],
    ];

    foreach ($metas as $metaKey => $metaFields) {
        foreach ($metaFields as $field) {
            if (isset($meta[$field])) {
                $meta_array[$metaKey][] = $meta[$field];
            }
        }
    }

    return $meta_array;
}
add_filter( 'really_simple_csv_importer_save_meta', 'really_simple_csv_importer_save_meta_filter', 10, 3 );
Share Improve this question asked May 27, 2019 at 14:57 GregoryGregory 6025 silver badges20 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Answear is available here with explaination (french). https://www.wpnuls.fr/import-csv-de-champs-acf-avec-really-simple-csv-importer-740.html

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745458066a4628579.html

相关推荐

  • advanced custom fields - help with really simple csv importer

    ( sorry for the title, but i dont know how to explain this as a title ^^ ).I'm using really simple csv importer to

    6小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信