2013年11月18日月曜日

WordPress importer 0.6でインポートできるようにする方法

importer 0.3を使えばいいのだけど0.3ではインポートした記事のカテゴリーが消えてしまうらしい
0.6を使う方法があったのでメモ

class WXR_Parser {
    function parse( $file ) {
        // Attempt to use proper XML parsers first
/*ここから      if ( extension_loaded( 'simplexml' ) ) {
            $parser= new WXR_Parser_SimpleXML;
            $result= $parser->parse( $file );

            // If SimpleXML succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result )|| 'SimpleXML_parse_error' != $result->get_error_code() )
                return $result;
        } else ここまで */if ( extension_loaded( 'xml' ) ) {
            $parser= new WXR_Parser_XML;
            $result= $parser->parse( $file );

            // If XMLParser succeeds or this is an invalid WXR file then return the results
            if ( ! is_wp_error( $result )|| 'XML_parse_error' != $result->get_error_code() )
                return $result;
        }

参考サイト