This is a much better and cleaner approach to auto-importing posts from anywhere.
It requires some use of code or of regular expressions scripts (outside of WordPress) though.
Basically, you need to create an import file for use with WordPress importer.
The best way to do it is like so:
- Export from WordPress an existing post that has all the elements in your posts.
You’ll need to use Tools -> Export. You’ll get an XML file where each post appears
between the tags <item> and the following </item>.
Find the representative post and delete all other posts (“items”) from the file.
This is an XML file, so now you’ll have opening tags, one item’s data and closing tags.
After every step, best using a localhost/temp copy of your blog, import the resulting file
(changing the post title to a descriptive one like “test no.1″ and so on.
Make sure the import was successful before proceeding to the next step.)
- To simplify the file (to keep it cleaner and because there’s a size limit
on the imported file), strip all info not requested by WordPress or part of your post.
(Again, with every tag (opening tag+data+closing tag) stripped, make sure that the file
continues to import without error messages.
For this example we used a basic post with title, content and one category,
And this is our resulted file:
<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wp="http://wordpress.org/export/1.1/" > <channel> <wp:wxr_version>1.1</wp:wxr_version> <item> <title>1</title> <content:encoded><![CDATA]></content:encoded> <wp:post_date>3</wp:post_date> <wp:comment_status>open</wp:comment_status> <wp:ping_status>open</wp:ping_status> <wp:status>publish</wp:status> <wp:post_type>post</wp:post_type> <category domain="category" nicename="4"></category> </item> </channel> </rss>
where 1 is the post’ title
2 is the post’ content
3 is our intended post’ publishing date and time
and 4 is an existing category “slug” name
Now all that’s left is to create a file with the same intro and outro structure
(everything before <item> and everything after </item>), and create your items
We had our content on MS Access, so we used VBA to create the formatted HTML from
query results, and now we can import any number of new posts with 3-4 clicks inclusive!
Of course, last step is Tools -> Import -> WordPress.
NOTE: for every item, you’ll get a message that says:
Failed to import author . Their posts will be attributed to the current user.
That happens because of some security feature, just ignore.
Would love an idea how to skip it all together though…