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

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".

Related

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.

bilingual custom field labels with ACF (free version)

I am using custom fields (with the free version of ACF) to add additional, sometimes required, formatted content to the respective custom post type entries. I put together a little site-specific plugin which includes filters to add the custom fields to excerpt and content and puts them out, via a loop, as a list of:
{CUSTOM FIELD LABEL}: {CUSTOM FIELD VALUE}
The website should be available in English and German. Using the Sublanguage plugin, I could translate most of the website, but not the custom field labels.
From what I read on i18n/l10n and Wordpress, I understood that I should best use __() for the labels when creating the custom fields. Since custom field creation is realized by ACF plugin code, I assume I have to create the fields "myself" so that I can do multilingual labels using __(). I guess, I would then realize the actual translation of the fields with Loco Translate.
ACF offers a neat way to export my already existing ACF-created field groups, which provides me with the PHP code to create the fields "on my own". I put the ACF code inside a new function in my site-specific plugin and hooked it to the acf/init action. I did pretty much the same as described in this question, but nothing happens: When I trash the custom field groups within the ACF interface afterwards, no custom fields appear in the "new post" screen.
So basically, I am having one question that, depending on the answer, will spawn follow-up questions:
Is this how I should and can realize bi/multilingual custom field labels?
If no: How else would you implement bilingual custom field labels/names?
If yes: Am I hooking the function to the wrong action?
PS: I wasn't sure if this belongs here or in the WP StackExchange, since part of it is coding related and part of translation-logic-related. Please tell me if I should move it over to the other platform.
Alright,
I was able to solve most of this myself in the meantime:
I did not hook into the correct action. As it turns out, acf/init is only available in ACFv5 (pro), while the free edition is still in version 4.x. I hooked into init - et voilĂ : there are my field groups.
Using __() functions to declare my custom fields' labels, Loco Translate made it quite easy to translate the strings myself.
Conclusion
Apparently, my assumptions were correct - this is how to create internationalized custom field labels :) Nevertheless, I wasn't able to effectively translate the options of a checkbox field I am using, although Loco recognized the string and I provided a translation.
However....
The solution is far from perfect:
I am now using two plugins to translate as much as possible on the website.
Creating the ACF field groups "myself" through PHP code in my site-specific plugin, I needed to remove them from the admin UI. This means, that it's going to be difficult for any standard users to change anything about them in the future (which might of course be a feature as well :))

Wordpress - form to capture the values for the custom post type

I want to add a new entity named "ideas" having different fields. I want to add this to the admin side, where a logged in user can add/edit new "idea", which can be published/unpublished to the site.
I don't want to edit via php and make things complicated, instead do it from the wp-admin log in front-end. Is there a plugin for this? I need 3-4 such entities to be created, and define fields for each such entity.
New edit:
Custom Post Type is the best option I feel. Can anyone suggest, a free plugin for form to capture the values for the custom post type?
According to this WCK - Custom Fields and Custom Post Types Creator plugin you can achieve this.
WordPress Creation Kit consists of three tools that can help you
create and maintain custom post types, custom taxonomies and most
importantly, custom fields and metaboxes for your posts, pages or
CPT's.
WCK Custom Fields Creator offers an UI for setting up custom meta
boxes with custom fields for your posts, pages or custom post types.
Uses standard custom fields to store data.
WCK Custom Post Type Creator facilitates creating custom post types by
providing an UI for most of the arguments of register_post_type()
function.
WCK Taxonomy Creator allows you to easily create and edit custom
taxonomies for WordPress without any programming knowledge. It
provides an UI for most of the arguments of register_taxonomy()
function.
Hope it helps you.
You can use a combination of two plugins to fit your needs:
The Custom Post Type UI (https://wordpress.org/plugins/custom-post-type-ui/) makes it possible to generate Custom Post Types (like "Posts" or "Pages") and Custom Taxonomies. This is how you can create your entity "ideas" which will show up in the admin menu.
With Advanced Custom Fields (https://wordpress.org/plugins/advanced-custom-fields/) you can define additional content fields for your "ideas"-posttype and others. It also can handle relations between your added custom-post-types
Using the SWIFT Templates as proposed in Touqueer Shafis answer will be sufficient when you only have smaller bits of information to display on the page or if you just want to display archives of your custom-post-types. But you will quickly reach the borders of these templates when it comes to single-pages.
I recommend altering the PHP of your template files manually: you will have more control where and when to display the contents of the custom-post-types and custom-fields you added on your page.
Well, I'm not really gonna give you the answer you want to hear but I want to give you an advice from my own experience.
Using a plugin will make things usually much more complicated than doing it manually. Consider some things:
1) The plugin may not be supported for ever (or long), so if the author decides that he or she wants to be a gardener instead of a developer you're screwed. Unless you want to wrap your head around the plugin code and proceed developing it on your own. This is especially true for "underground"-plugins which are not so popular and/or maintained by a single person. Although I think you CAN rely on the "big" players like "Advanced custom fields"
2) At some point you may find that the plugin you are using doesn't support some sort of customization that you really need and quite a few plugins are built in a way that makes it hard to extend them or break out from the way they work.
So I recommend you to wrap your head around custom taxonomies and post types and just add them with PHP in your functions.php or a custom plugin. It's very very easy (it's really just arrays with arguments). You could use this visual code generator as a starting point:
http://generatewp.com/post-type/
And for adding custom fields I recommend using Advanced custom fields. You won't need any other plugin for backend management customization and it's built in a way that you can even export your custom fields as php so if they ever drop support you still have a good starting point.

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

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.

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