[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
- The topic ‘[Plugin: CSV Importer] Making custom changes’ is closed to new replies.