Questions answered by this recipe
How can I import the content of my existing Wordpress blog into PmWiki?
I have been keeping a personal diary in Wordpress for several years. I am planning to move the content to PmWiki. This recipe describes my progress so far.
Importing entries is a two stage process. First Wordpress entries are exported as xml and saved to a file. The second stage is to parse the xml file and create a wiki page for each entry. In some cases my blog has more than one entry per page, in this case I concatenate the entries into a single page for that day.
Wiki pages are created in yyyymmdd format for easy sorting using the pagelist function. At the moment Wordpress categories are ignored completely - this is something I plan to address in the next version.
Other improvements are making the page title the same as the blog entry title, although this will cause problems where wiki pages have more than one blog entry.
You need to download two files for this recipe:
- wordpress_export_xml.phpΔ - exports entries in your blog as xml.
- pmw_convert.phpΔ - create wiki pages from the Wordpress xml file.
Edit both files where indicated to fit your needs. The directory where the wordpress exported xml file and the new wiki pages are created need to be writeable by your webserver.
This is very much an experimental release, so expect features and bugs to change on a regular basis:) The method used to clean characters that are not valid xml from the blog body is very crude. If anyone can improve this, please go ahead.
- I'm wondering why you don't use the wordpress export feature and
something like SimpleXML to manage the XML data? I recently wrote
something to convert a wordpress installation I was using more as a
CMS than a blog. It was interesting; I did it in Perl rather than PHP,
but it may be moderately useful for someone, so I'm attaching
wp2pm.pl.txtΔ--tamouse November 13, 2011, at 03:45 AM
Is there anything new about the page name == post title feature?
- Finar: I wrote a new script for one of my projects. If you have a WordPress website and you want to convert it's database into PmWiki, you can install wp-all-export plugin for Wordpress and make export to CSV. After this my script may be used to convert data into PmWiki pages, including uploaded files processing and backlinks processsing. Actually this is CSVtoPmWiki PHP-parser. If you need this script, contact me and I will publish this recipe.
The variable $query has a problem into pmw_convert.php. I modified it:
$query = "SELECT ID, post_date, post_title, post_status, post_modified, post_content FROM wp_posts ORDER BY ID ASC";