Title: [Plugin: CSV Importer] Making custom changes
Last modified: August 19, 2016

---

# [Plugin: CSV Importer] Making custom changes

 *  Resolved [alexleonard](https://wordpress.org/support/users/alexleonard/)
 * (@alexleonard)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-csv-importer-making-custom-changes/)
 * Hi there,
 * I’ve been finding this plugin extremely useful the last while but wanted to make
   a customisation and I’m not entirely sure how to go about it.
 * I need to prevent duplicate posts from being imported.
 * In my CSV I will always have a unique ID as one of the custom fields. I wanted
   to check this unique ID against all posts currently in the WordPress database.
 * I’m fairly sure for the PHP code I’ll just need to extract the CSV custom field
   ID, and then create an array of the matching custom field value of all current
   posts, then I can check if there’s a match using in_array. If it matches then
   I want to skip to the next line in the CSV and repeat that check.
 * I’m guessing it would go somewhere in here:
 *     ```
       foreach ($csv->connect() as $csv_data) {
       	if ($post_id = $this->create_post($csv_data, $options)) {
       		$imported++;
       		$comments += $this->add_comments($post_id, $csv_data);
       		$this->create_custom_fields($post_id, $csv_data);
       	} else {
       		$skipped++;
       	}
       }
       ```
   
 * but am not entirely sure. Can you give any pointers on how I might achieve this?
 * Cheers,
    Alex

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

 *  Plugin Contributor [dvkob](https://wordpress.org/support/users/dvkob/)
 * (@dvkob)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-csv-importer-making-custom-changes/#post-1856294)
 * alexleonard: Your approach sounds good. You can put that logic either in the 
   loop you posted or inside the create_post() method. [query_posts()](http://codex.wordpress.org/Template_Tags/query_posts)
   function will probably be of help.
 *  Thread Starter [alexleonard](https://wordpress.org/support/users/alexleonard/)
 * (@alexleonard)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-csv-importer-making-custom-changes/#post-1856391)
 * Hey dvkob,
 * Thanks for the quick response. Good to know my thinking is heading in the right
   direction.
 * Although it’s looking like I may actually, due to some quite strange requirements,
   have to allow duplicates to be imported, but not display them in my loops if 
   two separate required unique fields are not met. Quite confusing but I’m sure
   I’ll get there in the end!
 * Thanks again,
    Alex

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

The topic ‘[Plugin: CSV Importer] Making custom changes’ is closed to new replies.

 * ![](https://ps.w.org/csv-importer/assets/icon-256x256.png?rev=3039593)
 * [CSV Importer](https://wordpress.org/plugins/csv-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/csv-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/csv-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/csv-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/csv-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/csv-importer/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [alexleonard](https://wordpress.org/support/users/alexleonard/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/plugin-csv-importer-making-custom-changes/#post-1856391)
 * Status: resolved