WordPress export

WordPress is a very flexible blog publishing script – but it does depend on a server-side database and the ‘pages’ exist only as database reports. I’m moving over to a static page system (one that produces ‘real’ .html files on the server) based on the minimal blosxom script. I need a way of exporting all my posts from WordPress as a single text file.

The least technical way to do this seems to be to create a special theme (called ‘export’) that has just the text of each post – no html page tags. The total content of the index.php file for such a theme is shown below…
< ?php if ( is_home() || is_single() ) : ?>
< ?php if (have_posts()) : ?>
< ?php while (have_posts()) : the_post(); ?>
$$START
< ?php the_title(); ?>
< ?php print("/n"); ?>
Cat: < ?php the_category(', ') ?>
< ?php print("/n/n"); ?>
< ?php the_content(); ?>< ?php print("/n/n"); ?>
$$END
< ?php endwhile; ?>
< ?php else : ?>
poo
< ?php endif; ?>
< ?php endif; ?>
Once uploaded to a folder called (say) ‘export’ in the wp-themes folder along with a stub css file so the theme can be loaded properly by the wordpress presentation system, I set the Options to list 400+ posts on the home page and select the ‘export’ theme. I then View | Source in the Web browser and copy and paste the plain text into a text editor.

In the editor (Textwrangler or Textpad according to OS) I do a search and replace on the URLs of image files to point them to the new folder. Then I run a Grunge Perl™ script that chops the posts into separate files saved in folders that have the names of the categories – as blosxom needs. The results are OK so far, a few posts with ‘more’ tags embedded need sorting, and any links between posts need to be changed by hand.

Comments are closed.