用于通过 WordPress Importer 导入 WXR 文件中的数据,支持作者映射、附件处理和 URL 重写等高级选项。
适合在迁移或恢复网站内容时使用,可灵活控制导入过程中的作者分配和数据类型跳过。
| 参数 | 说明 |
|---|---|
<file>... |
一个或多个有效的 WXR 文件或导入路径。也接受目录。 |
--authors=<authors> |
如何处理作者映射。选项为 ‘create’、’mapping.csv’ 或 ‘skip’。’create’ 会从 WXR 文件创建不存在的用户;’mapping.csv’ 从 CSV 读取映射关系,若文件不存在则创建 CSV 供编辑;’skip’ 跳过作者映射。 |
[--skip=<data-type>] |
跳过导入特定数据类型。支持的选项:’attachment’ 和 ‘image_resize’(跳过耗时的缩略图生成)。 |
[--rewrite_urls] |
将所有指向原站点的导入 URL 重写为指向当前站点。需要 WordPress Importer 0.9.1 或更新版本。 |
$ wp import example.wordpress.2016-06-21.xml --authors=create
Starting the import process...
Processing post #1 ("Hello world!") (post_type: post)
-- 1 of 1
-- Tue, 21 Jun 2016 05:31:12 +0000
-- Imported post as post_id #1
Success: Finished importing from 'example.wordpress.2016-06-21.xml' file.