You can convert any column names with filter hooks. There is an example code on my blog post:
http://notnil-creative.com/blog/archives/2913
ok i think this was what i needed, now the other question i have is what can i add to that code to set the post_title and post_content values?
the code you sent me to is for mapping data to custom meta keys which seems like it will work exactly as i need it to, but the csv file i am using will also not have the post_title or other mandatory columns for importing so i will need to map them from the columns i have. ie i have a column called item-name that would need to map to post_title and then i have item-description and that would map to post_content
any help is appreciated, and if this works, which i think it will ill search your site for a donation button and toss you some money for beer 🙂
Please use really_simple_csv_importer_save_post filter instead. read the docs
yes i’ve read the docs, but i am very new to the whole wordpress filters and plugins area, so i am struggling to figure out how to combine the two solutions, as your demo shows how to match a post by unique key, and i cannot get the code correct to do all of the above in one run.
goals:
1. none of my csv columns have wordpress post names like “post_title” so i need to map “item-name” to “post_title” and other columns to the post table data. (post save function)
2. i also need to map “item-name” to “_vendor_item-name” in the postmeta table.(meta save function)
3.set post type to custom type
i am trying to adjust the really_simple_csv_importer_class to do this because it seems that it handles both $post and $meta in the same function, but not having a lot of luck.
Awesome plugin though, ill keep trying.
Thank you
never mind i figured it out, i was thinking too much into it. AWESOME plugin 🙂
now i just need to find an export plugin that does the reverse and can put it all back into csv in the original order.
* Not yet tested
<?php
/*
Plugin Name: Map custom post meta to plugin
Author: Takuro Hishikawa
Version: 0.1
Author URI: http://notnil-creative.com/
*/
add_filter('really_simple_csv_importer_class', function(){
return "CustomImporter";
});
class CustomImporter
{
public function save_post($post,$meta,$terms,$thumbnail,$is_update)
{
$itemName = $meta['item-name'];
unset($meta['item-name']);
$post['post_title'] = $itemName;
$meta['_vendor_item-name'] = $itemName;
$importer = new RS_CSV_Importer();
return $importer->save_post($post,$meta,$terms,$thumbnail,$is_update);
}
}