• I’ve recently migrated from using Textile to plain HTML and the WYSIWYG editor. Doing that, I tried the old method that was recommended here.

    I tweaked it a bit, and made it slightly more safe. Here’s the new way.

    But remember: Back up people! We’re really messing with the database here! And don’t just do “tools -> export” and don’t just save using PHPMyAdmin, use mysqldump to make proper backups!

    Paste this in your themes functions.php file:

    // Convert textile!
    function crs_convert_textile() {
    	global $wpdb;
    
    	if (!$_GET["post"]) { die(); }
    	$postID = $_GET["post"];
    
    	$postsout = $wpdb->get_results("select ID from wp_posts where ID = ".$postID.";");
    	$thiscontent = $wpdb->get_var("select post_content from wp_posts where ID = ".$postID.";");
    	$newcontent = apply_filters('content_save_pre',textile($thiscontent));
    	$wpdb->query("UPDATE wp_posts SET post_content = '$newcontent' WHERE ID = ".$postID.";");
    
    }
    
    if ($_GET["textileme"] == "do") {
    	crs_convert_textile();
    }

    Now browse your website. If you append ?textileme=do&post=<postID> where <postID> is the ID of the post you wish to update (you can gander the ID by looking at the URL in the statusbar, when you hover over the “edit this” link). For instance, ?textileme=do&post=2794 — if you do this, that post and that post only, should be updated with HTML in the database instead of Textile.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to convert Textile to HTML in the database, a new method inspired by the old’ is closed to new replies.