If you regularly work with many different projects in website development, especially the projects have the similar custom fields, this post will be useful for you. This guide will bring you an easy way to copy meta boxes and custom fields from one site to others with our Meta Box Builder.

Meta Box has an extension named Meta Box Builder, which helps you create custom fields in the blink of an eye by drag and drop the fields flexibly. It also lets you configure those fields easily on its UI without touching a single line of code. It is perfect for people even who don’t know any code whatsoever.

However, we don’t talk about that advantage of Meta Box Builder in this post. That is not our principal today. We are going to show another feature of it which helps you clone custom fields from a site to another in a simple way.

Benefits of cloning meta boxes and custom fields among sites

Actually, cloning is copying the code of the meta boxes / custom fields group created in a site, then embedding it into another site. That gives you the same functionality of these meta boxes and custom fields on the embedded site without installing any extension of Meta Box.

There are some benefits of cloning which you definitely are interested in:

It helps your embedded website operate with the adequacy of necessary custom fields and its configuration, but with much faster speed because of not installing any plugin for these custom fields beyond our ultra lightweight Meta Box Framework.

You only need to create a series of custom fields on local with an adequate configuration as you want. Then embed code of the needed fields in the target sites. That ensures that all of the fields which you import into the sites have the same settings. Of course, then you may not worry about having the same request for the same fields but configurations are different among projects. You also stop the memory of how you configure fields escapes you, whether it has the error or not.

It may not waste time anymore in the fields configuration with the complex attributions or conditions. You only do once, and clone to the sites you need. That’ll save a lot of times.

Please note that cloning meta boxes among sites is different to cloning a custom field inside a meta box. Learn more about cloning a custom field

Now, let’s figure out how to clone codes by Meta Box Builder.

Requirements:

Installed Meta Box Framework (on all of the sites which you need to create/embed code).

Installed Meta Box Builder (on the original website which you create fields)

In case you bought our Developer Bundle or Lifetime Bundle, you only need to install Meta Box AIO only because it has full of necessary plugins and extensions.

Creating meta boxes and custom fields

Create the meta boxes and custom fields inside through the UI of Meta Box Builder. Remember completely configuring all the fields.

In there, you can also use concurrently the other extensions of Meta Box to configure your custom fields as you want, ex: Meta Box Group, Meta Box Conditional Logic, Meta Box Geolocation, etc.

For example, I am trying to create the fields as below image:

Also, don’t forget the configuration in the options area:

Combining with setting up custom fields by Meta Box Conditional Logic:

Learn more about how to create custom fields with Meta Box Builder here.

Make sure that you published those fields, and those fields displayed as you want.

Exporting code of the custom fields

After publishing field group which you created, in the editing interface of the field group, you’ll see a tab “Code”. Click it, then you see the code of field group as below image:

You can manually copy that code to export it or take your mouse hover over the code, then button “Copy” appears to help you copy all of it quickly.

Pay attention to this code of a field group (as meta box) that you created. In case you need cloning an individual field only, you may create the corresponding meta boxes containing each needed field.

Embed code of field group in the targeted website

Open file function.php in the theme of the website which needs to embed code, then add the code to that file.

Remarks:

The targeted website doesn’t install Meta Box Builder but must install Meta Box Framework to ensure that the embedded code can operate. In case the target is the original website used to create fields, let’s deactivate Meta Box Builder on this site before embedding its code. If there has been the other code embedded in the file function.php and it has the same ID with the new code, only the last one is accepted. You can embed code of many different field groups in one site but must ensure that ID of each field group differs from others then all of the field groups can operate. If the field groups’ IDs is iterated, the last one will be prioritized as the 3rd remark point.

Finally, after adding code in sites, added field group is going to operate on the new site similar to the initial site without any hassle. The custom meta box and custom fields also display the same as the original site:

Conclusion

Do you see that it is simple? We have done it in the blink of an eye as the other features of Meta Box Builder. Now you don’t have to rebuild the custom field groups on the other websites. All you need to do is building once, then export and copy to the other websites. It’s pretty simple and fast. We hope with this tutorial, you’ll save a lot of time and effort in the future projects.