Converting WordPress to files

by Conner McDaniel

Recently my brother introduced me to a nifty idea. The idea is called Markdown, which is a text format that’s designed to be easily readable while at the same time having enough syntax to convert it to other file types (namely HTML). As is common with good ideas, others are working on making it even better. One such case is MultiMarkdown which attempts to allow the conversion of this text format to LaTeX, RTF, FODT and PDF. Furthermore, once a few people sunk their teeth into this epiphany, a HTML to Markdown converter was made so that others could convert their documents that were previously in HTML to this new format for storage and readability.

Right now, Markdown is still in its beginning stages and could really use some better stream-lining from products like MultiMarkdown to make it more popular, but I like the readability of the format more than the potential of conversion. For that reason, I decided that I’d pull all my HTML WordPress posts and convert them to this format for storage in case I ever changed the structure of my website. This proved to be tedious. Even getting the raw HTML out of WordPress is a bit tedious. WordPress has an export option, but it only allows you an XML file that you must then parse to get the real HTML out. So I had a sharp idea and ran with it. Why not do the HTML parsing and conversion at the same time? And furthermore, why not make it available to other people? So I wrote a quick script in PHP that will parse the WordPress Export XML and convert it to a desired format. There are a few options about how you want the folders and files to be named as well.

How to convert WordPress posts into files:

  1. Go to WordPress->Tools->Export
  2. Choose ‘Posts’ and then click ‘Download Export File’
  3. Fill out the form below with your desired settings
  4. Upload the XML file and click ‘Go’

This should download a ZIP file with your desired folder structure, file naming format, and conversion type. None of your files will be shared or stored on the server (they are deleted by the script after the download). If you’re having problems with it or are not sure how to use the options then ask in the comments below!

WordPress to Files

Folder format:

File name format:
(post-name or PHP date format string)

Data format:

Time zone:

XML file: