I'd like to export my blog posts to plain text files so I can version control and update them using emacs org-mode via the org2blog package. However, I'm unfamiliar with SQL and the wordpress database structure. I'm hoping to get ideas for a SQL script to export my posts where each post is stored to a file named "YYYY-MM-DD_Title-of-post.org" and where the files will look like:

#+POSTID: 1071
#+DATE: [2011-09-21 Wed 18:00]
#+OPTIONS: toc:nil num:nil todo:nil pri:nil tags:nil ^:nil TeX:nil 
#+CATEGORY: cat1, cat2, cat3
#+TAGS: tag1, tag2, tag3
#+TITLE: Hello World
### URL: http://...


The parts to be filled in is the DATE field, CATEGORY, TAGS, TITLE, URL, and BODY OF POST.

I think it might be asking too much to have someone do all my work for me. So, alternatively, I'd be content with a SQL script that outputs those fields in a delimited file, say delimited by "|||" so I can write a script elsewhere to get what I want.

Thanks for your help. Much appreciated!

2 Answers 2


The WordPress plugin repository has several "export to CSV" plugins available. For example this one looks interesting. Its also a good startpoint if you don't want to use a plugin and code this on your own.


I ended up exporting my posts to xml (an option in wordpress) and using the org2blog-importer tool that was just created by the author of org2blog to get the files into the format I wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.