Wordpress:高级自定义字段:将字段导出和导入到新的 wordpress 安装
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23505076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Wordpress: Advanced Custom Fields: Exporting and Importing fields to a new wordpress install
提问by Reuben
I've created two custom field groups in a temporary wordpress install and would now like to use the export of them to import them into a new wordpress install, however it doesn't seem like there's a way.
我在临时 wordpress 安装中创建了两个自定义字段组,现在想使用它们的导出将它们导入到新的 wordpress 安装中,但似乎没有办法。
How have others done this?
其他人是如何做到这一点的?
回答by doublesharp
Advanced Custom Fields stores the field groups as Custom Post Types, so the XML export is compatible with the standard WordPress XML format, and can be imported using the WordPress Importerplugin.
高级自定义字段将字段组存储为自定义帖子类型,因此 XML 导出与标准 WordPress XML 格式兼容,并且可以使用WordPress 导入器插件导入。
You can also get to the install directly by visiting /wp-admin/import.php
on your site (under Admin > Tools > Import) and clicking the WordPress link at the bottom. Once installed you just need to import the XML export file you created for the ACF field groups.
您还可以通过访问/wp-admin/import.php
您的站点(在管理 > 工具 > 导入下)并单击底部的 WordPress 链接来直接进行安装。安装后,您只需导入为 ACF 字段组创建的 XML 导出文件。
回答by antongorodezkiy
For importing from ACF 4 (exported to PHP) to ACF 5 Pro I used ACF-PHP-Recovery. Works like a charm.
为了从 ACF 4(导出到 PHP)导入到 ACF 5 Pro,我使用了ACF-PHP-Recovery。奇迹般有效。
回答by Nate
To build on antongorodezkiy's answer:
以 antongorodezkiy 的回答为基础:
His suggestion to use ACF-PHP-Recoveryworked for me, but I had to make a couple of other edits first. My ACF 4.x PHP export used the function "register_field_group". But the ACF websitereferences the function "acf_add_local_field_group". The property fields of both functions are almost identical -- the one major difference is that the old function used 'id' as one of its first keys, and the new function uses 'key'.
他建议使用ACF-PHP-Recovery对我有用,但我必须先进行一些其他编辑。我的 ACF 4.x PHP 导出使用了函数“register_field_group”。但是ACF 网站引用了函数“acf_add_local_field_group”。两个函数的属性字段几乎相同——一个主要区别是旧函数使用“id”作为其第一个键之一,而新函数使用“key”。
Making those changes to the PHP allowed the ACF-PHP-Recovery plugin to recognize my ACF data and import it.
对 PHP 进行这些更改允许 ACF-PHP-Recovery 插件识别我的 ACF 数据并导入它。
By the way, the generated PHP goes into your functions.php file. Once you've used the plugin to upload the data, remove the PHP from functions.php.
顺便说一下,生成的 PHP 会进入您的 functions.php 文件。使用插件上传数据后,从functions.php 中删除PHP。