【问题标题】:WordPress WXR SpecificationWordPress WXR 规范
【发布时间】:2012-03-10 11:55:13
【问题描述】:

我正在尝试查找 WordPress WXR 导入/导出标准的规范,但我无法从 WordPress 中找到有关该标准的任何官方文档。

有谁知道官方资源可以准确地告诉我如何生成 WXR 文件,以便自动导入 WordPress.com 或 WordPress 自托管网站?

我特别想为现有的 CMS 创建一个 WXR 导出系统,以便用户可以轻松迁移到 WordPress。

【问题讨论】:

    标签: xml wordpress import rss xml-parsing


    【解决方案1】:

    我向 WordPress 核心开发人员 John O'Nolan 提出了这个问题,他将我的问题转发给了核心提交者 Aaron Jorbin。 O'Nolan 回应说(我在解释)没有任何关于 WXR 标准的官方文档,但是对 WXR 导出进行逆向工程应该会给我我需要的所有信息。

    O'Nolan 还指出,比博客文章内容更复杂的数据可能最好通过数据库转换/迁移而不是导入来处理。我倾向于同意这里。

    我发现这两个链接有助于我对 WXR 标准进行逆向工程:

    http://ipggi.wordpress.com/2011/03/16/the-wordpress-extended-rss-wxr-exportimport-xml-document-format-decoded-and-explained/

    http://olalindberg.com/2008/write-your-own-wxr-file-to-migrate-custom-cms-to-wordpress/

    后一个链接专门处理附件,这对我当前的项目至关重要。

    我希望这对任何对 WXR 感兴趣的人有所帮助。

    【讨论】:

    【解决方案2】:

    对于那些没有 WordPress 导出但仍需要制作 WXR 文件的人,the code for the exporter 位于 WordPress 插件的 Trac 服务器上。下面摘录,从<rss> 节点到一对对象foreach 循环:

    <?php the_generator( 'export' ); ?>
    <rss version="2.0"
        xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
        xmlns:content="http://purl.org/rss/1.0/modules/content/"
        xmlns:wfw="http://wellformedweb.org/CommentAPI/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
    >
    
    <channel>
        <title><?php bloginfo_rss( 'name' ); ?></title>
        <link><?php bloginfo_rss( 'url' ); ?></link>
        <description><?php bloginfo_rss( 'description' ); ?></description>
        <pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
        <language><?php bloginfo_rss( 'language' ); ?></language>
        <wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
        <wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
        <wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
    
    <?php wxr_authors_list( $post_ids ); ?>
    
    <?php foreach ( $cats as $c ) : ?>
        <wp:category>
            <wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
            <wp:category_nicename><?php echo wxr_cdata( $c->slug ); ?></wp:category_nicename>
            <wp:category_parent><?php echo wxr_cdata( $c->parent ? $cats[$c->parent]->slug : '' ); ?></wp:category_parent>
            <?php wxr_cat_name( $c );
            wxr_category_description( $c );
            wxr_term_meta( $c ); ?>
        </wp:category>
    <?php endforeach; ?>
    <?php foreach ( $tags as $t ) : ?>
        <wp:tag>
            <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
            <wp:tag_slug><?php echo wxr_cdata( $t->slug ); ?></wp:tag_slug>
            <?php wxr_tag_name( $t );
            wxr_tag_description( $t );
            wxr_term_meta( $t ); ?>
        </wp:tag>
    <?php endforeach; ?>
    <?php foreach ( $terms as $t ) : ?>
        <wp:term>
            <wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
            <wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
            <wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
            <wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[$t->parent]->slug : '' ); ?></wp:term_parent>
            <?php wxr_term_name( $t );
            wxr_term_description( $t );
            wxr_term_meta( $t ); ?>
        </wp:term>
    <?php endforeach; ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-28
      • 2012-05-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多