Linux 软件免费装
Banner图

Really Simple CSV Importer

开发者 hissy
websoudan
更新时间 2026年7月16日 16:10
PHP版本: 3.6 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

acf csv importer cfs scf

下载

0.1 0.1.1 0.2 0.4 0.4.1 0.4.2 0.5 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.6.3 1.0 1.1 1.2 0.3 0.6.2 1.3.1

详情介绍:

Alternative CSV Importer plugin. Simple and powerful, best for geeks. You can get example CSV files in /wp-content/plugins/really-simple-csv-importer/sample directory. Available column names and values: Advanced Custom Fields plugin integrate If advanced custom field key is exists, importer will trying to use update_field function instead of built-in add_post_meta function. How to find advanced custom field key: Finding the field key Official public repository This plugin is now maintained by websoudan, taking over from the original author Takuro Hishikawa (@hissy). Thank you hissy for all the years of work! Add star and read future issues about rs-csv-importer on GitHub! Thanks Cover banner designed by @luchino__

安装:

  1. Upload All files to the /wp-content/plugins/ directory.
  2. 通过 WordPress 的“插件”菜单激活插件。
  3. Go to the Import page under Tools menu.
  4. Click CSV link, read the notification, then just upload and import.

升级注意事项:

1.0
  • wp_post_helper class is deprecated.

常见问题:

Should I fill all columns of post data?

No. Only columns which you want to update.

Can I update existing post data?

Yes. Please use ID field to specify the existing post.

Can I insert post with specific post id?

Yes. Please use ID field to specify the new post ID.

Can I import custom field/custom taxonomy of the post?

Yes. You can use column names same as wp_post table, but if the column name does not match, it creates a custom field (post meta) data. Importing custom taxonomy is a bit more complicated, "tax_{taxonomy}" means, "tax_" is prefix, and {taxonomy} is name of custom taxonomy (not labels). Here is an example. csv file "post_title","released","tax_actors" "Captain Phillips","2013","Tom Hanks, Barkhad Abdi, Barkhad Abdirahman" imported post data Post Title: Captain Phillips Custom field "released": 2013 Custom taxonomy "Actors": Tom Hanks, Barkhad Abdi, Barkhad Abdirahman

Why should I quote text cells when I save csv file?

Because PHP cannot read multibyte text cells in some cases.

Locale setting is taken into account by this function. If LANG is e.g. en_US.UTF-8, files in one-byte encoding are read wrong by this function.

Can I insert multiple values to CFS or ACF fields like Select or Checkbox?

Yes. Please create additional plugin and use really_simple_csv_importer_save_meta filter to make array data. Add-on development example

Can I import multiple files as attachments into a post?

Here is an example, assuming you have a field called cf47rs_images, format the csv cell data as, http://localhost/websitename/photos/photo12345-1.jpg|http://localhost/websitename/photos/photo12345-2.jpg|http://localhost/websitename/photos/photo12345-3.jpg or some other urls of files you want to import, and then use the really_simple_csv_importer_save_meta filter to hook into the import process, `add_filter( 'really_simple_csv_importer_save_meta', 'rsc_import_images',10,3); function rsc_import_images( $meta, $post, $is_update ) { //convert to an array $images = explode("|",$meta['cf47rs_images']); $meta['cf47rs_images']=array();//reset the meta field //directory to import images to $artDir = 'wp-content/uploads/imported_cf47rs_images/'; //if the directory doesn't exist, create it if(!file_exists(ABSPATH.$artDir)) { mkdir(ABSPATH.$artDir); } require_once(ABSPATH . 'wp-load.php'); require_once(ABSPATH . 'wp-admin/includes/image.php'); global $wpdb; //loop through each photos that need to be imported foreach($images as $file_url){ //let's get the image file name $new_filename = array_pop(explode("/", $file_url)); //move the file to our custom import folder if (@fclose(@fopen($file_url, "r"))) { //make sure the file actually exists $siteurl = get_option('siteurl'); $skip_attachment_insert=false; //check if this image has already been imported, if(file_exists(ABSPATH.$artDir.$new_filename) ){ //file already imported //either change the name of the file UNCOMMENT the following line //$new_filename = date("Y-m-d H:i:s").$new_filename; //.... or overwrite it, COMMENT OUT the next 3 lines of code if you choose to uncomment the renaming of file name. //in which case we want to find the attachment ID and store it in our meta field $attach_id = attachment_url_to_postid($siteurl.'/'.$artDir.$new_filename); $meta['cf47rs_images'][$attach_id] = $siteurl.'/'.$artDir.$new_filename; //no need to insert a new attachment, we reuse the same $skip_attachment_insert=true; } //(over)write the new file copy($file_url, ABSPATH.$artDir.$new_filename); if($skip_attachment_insert) continue; $file_info = getimagesize(ABSPATH.$artDir.$new_filename); //create an array of attachment data to insert into wp_posts table $artdata = array( 'post_author' => 1, 'post_date' => current_time('mysql'), 'post_date_gmt' => current_time('mysql'), 'post_title' => $new_filename, 'post_status' => 'inherit', 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_name' => sanitize_title_with_dashes(str_replace("_", "-", $new_filename)), 'post_modified' => current_time('mysql'), 'post_modified_gmt' => current_time('mysql'), 'post_type' => 'attachment', 'guid' => $siteurl.'/'.$artDir.$new_filename, 'post_mime_type' => $file_info['mime'] ); $uploads = wp_upload_dir(); $save_path = $uploads['basedir'].'/imported_cf47rs_images/'.$new_filename; //insert the database record $attach_id = wp_insert_attachment( $artdata, $save_path ); $meta['cf47rs_images'][$attach_id] = $siteurl.'/'.$artDir.$new_filename; //generate metadata and thumbnails, comment this out if you don't want thumbnails if ($attach_data = wp_generate_attachment_metadata( $attach_id, $save_path)) { wp_update_attachment_metadata($attach_id, $attach_data); } } } return $meta; } `

更新日志:

1.3.1 1.3 1.2 1.1 1.0 0.6.3 0.6.2 0.6.1 0.6 0.5.7 0.5.6 0.5.5 0.5.4 0.5.2 0.5.1 0.5 0.4.2 0.4.1 0.4 0.3 0.2 0.1.1 0.1