Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Oh, and then pull it out of your 404 page post-haste. You don’t want anybody else doing this again after you did it once (unless you trust Textile to reformat HTML; I don’t).

    Make a database backup before you try this.

    I put this into my-hacks.php (and it is indeed a hack):

    <?php function crs_convert_textile() {
    global $wpdb;
    $postsout = $wpdb->get_results("select ID from wp_myblog_posts where ID > 0;");
    foreach ($postsout as $thispost) {
    $thiscontent = $wpdb->get_var("select post_content from wp_myblog_posts where ID = $thispost->ID;");
    echo "$thispost->ID<br />n";
    $newcontent = apply_filters('content_save_pre',textile($thiscontent));
    $wpdb->query("UPDATE wp_myblog_posts SET post_content = '$newcontent' WHERE ID = $thispost->ID;");
    }
    } ?>

    (Replace “wp_myblog_” with the prefix for your own databases.)

    Then I added this to my 404 page before the footer:

    <?php crs_convert_textile(); ?>

    Now browse to a page that does not exist. If it ends in a timeout error, scroll down to the bottom of the page that was returned and note the last number that is listed; in my case it timed out after 30 seconds on post 221. Then I updated this line:

    $postsout = $wpdb->get_results("select ID from wp_myblog_posts where ID > 0;");

    To be like this:

    $postsout = $wpdb->get_results("select ID from wp_myblog_posts where ID > 221;");

    Repeat until you are through all your posts.

    I didn’t test this at all, other than using it on my own site. I did do a backup before I started. I didn’t use this on comments or excerpts or anything like that. It does seem to have worked. If you have posts that show up with other errors, make note of their number and change those manually (I had one with a complicated escaped table that didn’t make it through and I had to manually reformat that).

    When finished, turn off your Textile plugin. I used the Textile 2.6 plugin that is compatible with WP2, and I was running WP2.0.2 when I did this (this afternoon).

    Caveat lector! This is scary and I’m glad it worked for me; I hope it works for you but this is a wholesale swap of a lot of content.

Viewing 2 replies - 1 through 2 (of 2 total)