Wordpress: Advanced Custom Fields: Exporting and Importing fields to a new wordpress install - wordpress

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.
How have others done this?

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 Importer plugin.
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.

For importing from ACF 4 (exported to PHP) to ACF 5 Pro I used ACF-PHP-Recovery. Works like a charm.

To build on antongorodezkiy's answer:
His suggestion to use ACF-PHP-Recovery worked 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 website references 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'.
Making those changes to the PHP allowed the ACF-PHP-Recovery plugin to recognize my ACF data and import it.
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.

Related

Is there a quick and easy way to export-import WordPress meta-fields with renaming them?

I need to switch the meta fields plugin (From MetaBox to ACF), but my old fields was named in cyrrilic, which ACF does not support (at least, its visual interface). Is there an easy way to export meta-fields with renaming them and then import them back?
Have you tried exporting the fields to json? When you are in the ACF interface, at the top click on "tools" then "export".

Extract dimensions from one field using PHP in WPAllimport

I would like to extract dimensions length, width and height from a single value 51x51x21cm into 3 separate fields using PHP in the Wordpress plugin WPAllimport.
Any idea how to solve this?
Thanks!
Menno
I use WP All Import frequently and it sounds like you will need to do one of the following:
Reformat your data in a spreadsheet software (i.e Microsoft Excel)
Using WP All Imports custom function editor, create a custom PHP function to split the data into 3 separate values and use their inline PHP syntax to output each value accordingly
If you have experience with PHP, the custom function editor mentioned above should be at the bottom of the "Edit Import" page when creating or editing an import. You can find more about the custom function editor here.

Disappearing ACF field reference on non-imported field after running an import with WP All Import

So here is my setup, we have a custom post type (products) that uses ACF fields. We import the content for this custom post type using WP All Import from an in-house API.
The field in question is a Repeater field and is excluded from and explicitly ignored in the import I setup for this. I did this in the import settings of the specific import by checking "Update existing products with changed data in your file." Under that I have "Advanced Custom Fields" checked. Under that, I have "Leave these ACF fields alone, update all other ACF fields". And under that, I have my ACF field and all the fields under it included.
These items are excluded because we want to manually enter the information via the CMS admin.
When I run the import everything looks fine. But when I load the products that have this repeater field filled out it loads nothing on the product page. If I load the edit page for this product in admin, the information is still there. When I hit save and then revisit the product page the data shows up again.
Doing some digging today with xDebug, I found that the reference to the field for this post ID in wp_postmeta goes away. BUT the reference to the fields within the Repeater field still exists. So it is just this parent Repeater field that seems to be the problem. All of these are in that exclude list mentioned above.
We are using the following plugins that are related to this:
Advanced Custom Fields PRO (5.8.11)
WP All Import Pro (4.6.1)
WP All Import - ACF Add-On (3.2.6)
We also have Yoast SEO and other plugins installed, but seem unrelated to this. I will mention that Yoast fields are set to ignore and don't seem to have a problem. I am also running Wordpress 5.4.2.
Does anyone know what is going on and how to fix it? I am at a loss right now.

Can Advanced Custom Fields be built into a custom wordpress theme i.e. fields can be determined immediately when a user installs the theme?

So say I create some custom fields which can be edited via the front page editor.
I save these changes and want users of my theme to be able to see all of the custom fields I have made as soon as the theme is installed
This way, i can create a theme with pre-defined custom fields all over the website so users who install the theme can edit the custom fields straight away.
Otherwise, all the work done via advanced custom fields is rather pointless as when the theme is packaged, the user won't have access to the database that stores the files. I hope what I am asking makes sense!
EDIT: If this is not possible at all then I would accept that as an answer. If it is not possible then I would need to export then import the database for the made custom fields to display on a client's machine after they install the theme correct?
Totally reasonable question, and something that ACF has thought about and created a guide for. There are basically two parts to this guide, which I'll summarize below:
The actual ACF plugin must be included with your theme, which you can do by either:
Bundling the actual ACF PHP code with your theme (the actual plugin files)
Or, provide a link to the ACF plugin page and prompt users to install the plugin as part of your theme readme.
Including the specific custom fields that go with your theme - this is what your question is mostly asking about. Again, a few different ways to do this:
As a new feature of ACF, you can register custom fields with your theme by using JSON files instead of storing the configuration in the SQL database. This is what I personally use, since it is crazy easy to configure (just create an acf-json folder in the root of your theme) and allows you to use version-control (like GIT) to track custom field changes.
If you prefer the old way, you can register your custom fields in your theme's functions.php file.
Some additional information I can provide:
What about the storage of ACF values, not the configuration?
There is only one "database" for a given Wordpress installation, and the way ACF stores values that users have entered for custom fields with a given post is in the "wp_postmeta" table, by association the value with the post ID, field label (changeable), and field ID (permanent).
This is actually beneficial to you as a theme developer, because it means that if a user does something like installs your theme, enters a bunch of custom field values, accidentally uninstalls your theme or switches to a different one, and then wants to re-enable it, no data is lost.
Ensuring ACF gets installed with your theme
If you choose not to bundle the ACF source with your theme, and instead prompt users to manually install the plugin through the plugin directory, you might want to put some checks into your theme to ensure they do so. You can use something like if(!function_exists('the_field')){ /* Block use of your theme until installed */ } in some strategic spots in your theme code to check if ACF is installed, and if it is not, handle that appropriately and prompt admin to install.

Add custom fields while add/edit wordpress category

I am using WP-3.5.1 and want to know how can we add more custom fields (image, radio, check-box, drop-down) while adding/editing category?
I found http://en.bainternet.info/2011/wordpress-category-extra-fields but first here author did not mention
Where to add his code?
For which version of wp this code be use?
What affect if we upgrade to latest version?
What must be pass extra_category_fields( $tag ) in?
so I start from wp-admin/edit-tags.php and paste his code right after where Slug field is defined but stuck on $tag what should be pass here?
Is there any plugin to add custom fields in category like More Field which is for posts?
First thing, there is a big red warning in that page:
So, clearly, you'd better use the new version.
Second, you should never modify core files (/wp-admin/edit-tags.php). The following Q&A explains where you should put code enhancements in your WordPress site:
Where to put my code: plugin or functions.php?
Restore your core files to its original state using the following instructions.
Try to always use the latest version of WordPress, Themes and Plugins, as having old code in your site may have serious security/performance implications.
The new version of Taxonomy Extra Fields has much more examples in its documentation, so probably your configuration doubts would change.
All that said, the plugin Advanced Custom Fields is able to put extra fields in Taxonomies (categories, tags, custom taxonomies) very easily, no coding required.
Okay:
To add image filed while add/edit category use this plugin it is awesome plugin.
http://wordpress.org/extend/plugins/categories-images/

Resources