28
Mar
Posted by admin as wordpress
Problem: I have a big excel spreadsheet with posts and extra fields and I want to import it into Wordpress.
I haven’t found a plugin to do this so I decided to make my own. It’s not complete, and it’s not quite a ‘plugin’ but it works. Here’s how to do it:
- Download CSV_Import class from me. csv2 post.
- Unzip and up load the file called csv.php to /wp-admin/import/
- Prepare your csv file, here is a sample file. It’s really a pipe delimited file. It MUST follow this format or it will not work. Make sure you include the header row.

- In admin panel , go to Manage, Import, choose CSV
- The rest is pretty self explanitory, upload file, pick a user, and voilá
49 Responses
Your Seventh Loyal Reader
April 1st, 2008 at 5:05 pm
1NICE. I’ve been searching for something like this for-ev-er. I’m about to use it to create 288,000 pages. I will probably break it down into bite size chunks so everything doesn’t choke and die.
Any idea how many this can handle. Oh, and can I create unlimited (16 or so) fields with this? And can it create pages also or just posts? Sweet ass work, get a donation button doood.
Your Seventh Loyal Reader
April 2nd, 2008 at 2:08 pm
2I am having troubles… can you look at this text file and help me figure out what I’m doing wrong?
wp_title|wp_post_date|wp_category|wp_content|zip|website|phone|attorney|position|sex|employees|revenue
A Conflict Management Ctr|12/31/07 23:59|anchorage|310 K St # 200|99501-2064|Not Available|9072646687|Not Available|Not Available|Not Available|6|1002000
A Fred Miller Attorneys At Law|12/31/07 23:59|ketchikan|426 Main St|99901-6316|Not Available|9072256666|A Fred Miller|Owner|Male|5|835000
A Robert Hahn Jr|12/31/07 23:59|anchorage|1500 W 33rd Ave|99503-3639|Not Available|9072791544|A Robert Hahn Jr|Not Available|Male|2|334000
admin
April 2nd, 2008 at 2:52 pm
3Hey 7th loyal reader!
First things first, I’m glad you liked the code…even if it hasn’t worked for you yet.
I haven’t tested the code on WP 2.5 yet. The problem with your file though I think is the date format. You must follow
YYYY-MM-DD HH:MM:SS:MS
(dashes not slashes)…hope that was it.. let me know.
michael
April 12th, 2008 at 5:13 am
4thanks for this awesome plugin.
i am working on a new project and need to import about 2000 posts.
every post includes an excerpt and data for the plugin “All in One SEO Pack”.
can i import these fields as well?
i assume i have to look in the mysql table for the corresponding table name and just add it to the csv file.
admin
April 12th, 2008 at 6:04 am
5Hey Michael,
Sorry man…excerpts are not officially supported yet. I’ll work on it. Check back. Another thing, the plugin uses all WP functions…doesn’t talk directly to MySQL.
Nick
April 12th, 2008 at 11:27 am
6Hey Zack,
I usually build my websites tree on spreadsheet so I will have the different levels of the website [categories(first level)--> subcategories(second level) --> sub-subcategories(third level)] deployed there.
I would like to import this into WP.
Is there a way to achieve this with your plugin?
admin
April 12th, 2008 at 2:33 pm
7Hey Nick,
I’m currently adding support for cats/subcats. Check back.
michael
April 13th, 2008 at 12:04 pm
8thanks for the update Zack,
you saved me hours of mindnumbing work.
Nick
April 14th, 2008 at 8:35 pm
9Hey Zack,
Thanks for your reply. I already checked the update you posted but still can´t make it to do what I need…can I create with the updated version you posted sub-categories already?
If yes, could you provide a short example of the required syntax to define properly the child categories? Already tred but got no luck.
It would be great REALLY to have as many child categories created as desired.
Also, like mentioned above by Michael, the possibility to have titles, tags, etc passed to the All-in-One-SEO-Plugin would be Heaven.
All heavy WP users use it extensively so if you achieve this, your plugin is gonna rock for sure.
Thanks again for your time and keep it up! Looking forward for the updates.
Nick
April 15th, 2008 at 3:46 pm
10Any news Zack?
admin
April 15th, 2008 at 5:32 pm
11Hey Nick, see the new post
Nick
April 16th, 2008 at 7:18 am
12Hey Zack,
Nice job…worked like charm. I am not sure if I missed it but are we able with the new version to pass parameters to the All-in-One SEO plugin?
Not sure if this can be achieved via the additional field tags…
Cheers
Nick
April 16th, 2008 at 7:21 am
13Actually, would be great if you could provide a quick overview of how we’re supposed to use the extra fields & excerpts columns…
michael
April 17th, 2008 at 2:13 am
14Hey Nick,
you can pass parameters to the All-in-One SEO plugin with csv_import.
just add “all-in-ONE SEO” custom fields to the txt file. put the “key” in the first row, and the values below.
logan
April 20th, 2008 at 2:14 pm
15thanks! a lot.. this worked like a charm!
Adam
April 23rd, 2008 at 5:34 am
16Hi Zack, thanks for the plugin. I’v not managed to get it to work yet though. After selecting my file and then clicking import I’m getting this message:
Import CSV
Warning: Cannot modify header information - headers already sent by (output started at /content/DesignerPlus/l/o/mydomain.co.uk/web/wp-admin/admin-header.php:16) in /content/DesignerPlus/l/o/mydomain.co.uk/web/wp-includes/functions.php on line 2448
Any ideas? As usual it’s probably something dead simple but I’ve just not worked it out yet. I think this site is on wordpress 2.0.4.
Thanks
nevergivemyname
April 24th, 2008 at 11:20 am
17Just tried it out for 5 minutes but it looks really good so far !
ImportingPages?
April 26th, 2008 at 8:19 pm
18How we can modify the plugin to import pages?
Thanks!
admin
April 26th, 2008 at 8:38 pm
19I’m not sure how much work would be involved in changing the code to import pages instead of posts. The line/function used to import the post is
$post_id = wp_insert_post($postdata);
I started looking into what function is used to create a page and I can’t seem to find it (granted, I only looked for about 5 minutes). If anybody has the patience to find it, let me know, maybe I can add an ‘import page’ feature.
Your Seventh Loyal Reader
April 28th, 2008 at 5:30 pm
20Hi there -
I still can’t get this to work for me… I’ve tried on a few version of WP. In some of my field values I am using spaces - does that matter? Does white space matter at all?
thanks!
Your Seventh Loyal Reader
April 28th, 2008 at 6:16 pm
21I’m having such a hard time with this. Can I send you my text file to take a look at? I have tried so so many different things and it is just not working.
I have changed my date format as suggested, and in fact I have changed tons of things. I am saving a CSV from excel, opening in a Mac text editor, replacing my commas with pipes, and then saving as a .txt. Any help is much appreciated.
<B
Your Seventh Loyal Reader
April 28th, 2008 at 6:47 pm
22I got it now — If any Mac users are out there going from an excel CSV to a text file, export from excel as a CSV(Windows) file in the sace as options. Duh, I feel like saying to myself, hopefully this will save someone else some time. Plug in rocks!! Thanks for your work Zack.
Nick
April 28th, 2008 at 8:30 pm
23Hey Michael & Zack,
I´ve tried to insert the proper “keys” in the txt file to pass values to the All in One SEO plugin…I want to pass value for theses variables in the plugin: title, meta description & metakeywords.
Can you help me achieve this? Just a small example to clarify which are the correct “keys”?
Thanks in advanced guys!
Nick
April 30th, 2008 at 4:23 pm
24Any help here guys?
ImportingPages?
May 9th, 2008 at 4:41 am
25There are no difference between post and pages just the “post_type” field which has to be “page”
Loren
May 10th, 2008 at 5:35 pm
26Hello: I’ve been looking for something like this! Thank you! I try to import and get the message “The uploaded file could not be moved to …httpdocs/wp/wp-content/uploads/2008/05. 121″. What am I doing wrong?
admin
May 10th, 2008 at 7:04 pm
27Hi Loren,
wp-content needs to be writable by the server. Make sure permissions are right. Maybe that’s it.
Zack
lemon.head
May 14th, 2008 at 2:42 am
28Hi!
I am interested in contributing to the development of your tool. What I’d like to have:
* possibility to import pages instead of posts
* control more columns than just the four you have.
* define default values for other columns
* column “id” to modify existing posts.
* export csv (with ids) for easy mass manipulation in excel. This export could happen automatically with every import.
Do you have a repository somewhere, where I could contribute?
Please contact me if you are interested in cooperation!
admin
May 15th, 2008 at 7:08 am
29Hi LemonHead
Thanks for offering! Your ideas are great. I don’t know what repository to host the project. I don’t know if this script really qualifies as a plugin to submit to Wordpress.org because it runs under the admin/import section and not /plugin. I could be wrong…it may not make a difference to Wordpress under what dir the script runs. Anyway, I say this because they (wordpress.org) use SVN to keep versions of plugins and maybe we could collaborate through that. If you have any ideas on which repository to use please let me know. This could really turn into a great project.
Joe
May 15th, 2008 at 1:40 pm
30Great it works like a charm
Thanks a lot
lemon.head
May 15th, 2008 at 7:48 pm
31And another one
* allow more flexible input format
I prefer to not publish my email in public, but I hope you can find it on the admin backend.
About the repository. So far I have not bothered to get my own repository running somewhere. WP.org seems like an easy solution, so why not have a try.
Btw, I don’t find an rss link for the comments. I would like to keep up to date!
Thx, lem.
Max
May 16th, 2008 at 12:36 am
32Hello,
Thanks for your great plugin first. Is it possible to have tag(s) support?
lemon.head
May 19th, 2008 at 5:47 pm
33Now gave it some MVC, made the variables more local (I don’t like methods to communicate via class-scope variables), and made some things more logical (or what I perceive as more logical).
It’s going quite well, but now I am arriving at the tasty part, the process_post method, which at some point calls the WP function wp_insert_post(..). I am sure I can bite my way through, but I would be happy about some assistance and someone telling me what’s the idea behind all the lines of this function. Sometimes I think I can magically simplify things, but miss some of the original ideas which have been behind.
Another function which I don’t fully get is the get_tag() method. Is the user expected to put some XML tags into the input table?
Would be great if you can lighten me up a bit
dewaji
June 8th, 2008 at 7:12 pm
34Nice plugins. But, how about if I want to put tags in there ? how to make it.
For example :
wp_title|wp_post_date|wp_category|wp_content|tags|field2|field3
I want to make it like this :
wp_title|wp_content|wp_category|wp_post_date|tags1, tags2, tags3, moretags
Lionel Chollet
June 18th, 2008 at 3:06 pm
35Any way to insert custom slug/post_name?
I’d like to order posts by post_name (different than the sanitized post_title).
In my site’s scheme, post_title is the book’s title, post_name/slug is the book’s reference number.
Max
June 24th, 2008 at 2:26 pm
36Hi, looks like a great plugin.
I’d like to use it to import datafeed items with images. How would I add an image field into csv and connect it to the post (wp-content)?
thanks.
Max
June 25th, 2008 at 6:12 pm
37Hi,
I looked at discussion about All-in-one SEO plugin… How exactly txt line will look? Anybody can give an example?
…|wp-content|All-in-one SEO|tags
…|fun staff|Title: Post1, Description: test desc|test tag
????
Anybody can help please?
Nick
July 12th, 2008 at 11:48 am
38Hey guys,
I am having issues while importing posts…for instance, whenever I have a new line or starting a tense on a different line the plugin assumes it’s a new post….any ideas on how to solve this?
Thanks a lot!
Nick
kamu
July 29th, 2008 at 8:15 pm
39I tried to import post using rss/xml format but i had problem with the custom field. then someone suggested me to try this and voila! its working perfectly!
a million thanks to you zack.
Mike Smith - Bootstrapping Blog
August 4th, 2008 at 1:00 am
40awesome work here. I do have a question though.
Do you know how to merge three cell columns together? ie: A, B and C
I have a csv file thats got 3 columns for different information but I need it all to go into one so I can add it into the wp_content column.
Any help is appreciated.
Thanks
Frank
August 12th, 2008 at 12:25 am
41I think this is perfect for what I need… only problem is it’s not importing the content. Instead, it’s putting, for example from your sample, “My Post Title” and “Another Post” into the title and content fields.
I’m using Wordpress 2.6. Thanks a ton! If I can get this to work, you’ll have saved me hours of work!
Frank
August 12th, 2008 at 12:32 am
42Ok, disregard my last comment. I must have had a something wrong. It’s working perfectly now! Thanks!
Do the spaces between the text and the pipe have to be spaces, or are tab’s ok?
Thanks again!
Marc Juneau
August 22nd, 2008 at 12:05 pm
43All that is needed to make a “post” a “page” is one variable
online 292 of your script change:
$post_type = “post”;
to
$post_type = “page”;
im no php whiz
but this seemed to work! i tried it with your test csv after only changing that one line and the sample shows up in my pages area of wordpress
by the way .. you ROCK thank you for posting this plugin i have been wanting something for this forever!
DiamondGeezer.com
August 24th, 2008 at 9:21 am
44Is there a limit to the characters in wp_content
mine contains the following:
REBECCA is between 20 and 30 and is in a relationship (but not yet engaged or married). Rebecca LOVES the brand-name DiamondGeezer.com. and described the Diamond Geezer web site as EXCELLENT.She added ……TextPad loads an entire file into memory when you edit it, so the original file is not changed until you save the changes. You can opt to keep the original file as a backup when saving changes, and to keep it locked while you edit it.
But ends after She added ……
chantal
August 25th, 2008 at 8:17 am
45Hi
This looks really great… just one, probably dumb question… how do I get a csv file to be pipe delimited?
chantal
August 25th, 2008 at 8:24 am
46aarg dont worry… typically after spending 2 hours online etc to figure it out, I got it together after writing this note… apologies!
Bob
October 28th, 2008 at 12:43 pm
47Hi,
need your help here:
uploaded the csv.php file to my plugins folder, but it doesn’t show up in the plugins dashboard?
I’m using wordpress 2.6.2 - is it working with that?
how can I fix this?
thanks a lot for your help,
bob
admin
October 28th, 2008 at 3:07 pm
48Hi Bob,
This is not a traditional plugin. It goes in the wp-admin/import folder. You will see the link under Manage|Import
Zack
Bob
October 29th, 2008 at 10:35 am
49Ah, great, now I got it. Thanks a lot, this is just what I was looking for.
Am still trying to figure out the details with how to do long posts with several paragraphs, currently it breaks them up into separate posts for some reason.
Thanks again!
RSS feed for comments on this post · TrackBack URI
Leave a reply
Pages
Archives
Blogroll
Meta
Recent Posts
Categories
Recent Comments
Tags
advice bald careca Outrage psychology rant womenZack Preble is proudly powered by WordPress - BloggingPro theme by: Design Disease