Migrating custom post type and fields from Pods to Meta Box
We will move all the data of the custom post type and custom fields created with Pods to Meta Box easily following these few simple steps.
Video Version
Overall
Both Pods and Meta Box use two WordPress standard functions: get_post_meta()
and update_post_meta()
.
Besides, these two plugins save the custom fields' data in the same way: save each field in a line on the post meta table with the meta_key
field’s ID and the meta_value
field’s value.
Therefore, to move data from Pods to Meta Box, we just need to create new fields in Meta Box that have the same IDs as the corresponding fields in Pods. As for the custom post types, the method is the same.
I’m going to move data of the Project custom type and its custom fields from Pods to Meta Box. In this case, I’ll move only the data of custom fields for posts. You can apply the same method for terms and users.
Preparation
As I said, we will create a custom post type and custom fields in Meta Box, so we need it along with some of its extensions:
- MB Custom Post Types & Custom Taxonomies: to create custom post types easily. It can run without Meta Box. Otherwise, you can try Post Type Generator.
- Meta Box Builder: to create custom fields with an intuitive interface in the backend. If you don’t want to use this premium extension of Meta Box, you can use the free tool provided by Meta Box in the simplified version of Meta Box Builder - Online Generator.
1. Getting the post type’s slug & custom field’s ID in Pods
I already have the Project post type created with Pods. Its slug is ‘project’. You can see it in the Name column:
In the Project post type, there are two custom fields. Their IDs are project_name
and project_description
.
These are posts in the Project post type created by Pods:
And these are the custom fields in the Project post type:
Now, deactivate the Pods plugin. After that, the data of Pods is still in the database.
2. Creating a custom post type and move its data from Pods to Meta Box
First, activate the Meta Box plugin and its extensions.
Then, go to Meta Box > Post Types > Add New. Fill in the information for the new post type, and note that its slug must be the same as in Pods.
After that, the new custom post type will display in the Admin Menu. When you open the new post type, you will see all the old posts of the Project post type that you created with Pods previously.
Especially, the post information such as post title, post content, ... is still kept.
That’s how we’ve done for moving the posts content.
3. Creating custom fields and move their data from Pods to Meta Box
Go to Meta Box > Custom Fields > Add New to create new fields corresponding to the fields in Pods.
Pods and Meta Box support many different fields. Therefore, every time you add a new field with Meta Box, it must have the corresponding field type. This makes sure that the data of custom fields are saved in the same method.
For example, the corresponding field type of paragraph text (Pods field) is the text area (Meta Box field).
Similar to the previous step, you must enter the corresponding IDs for the custom fields. You can use the different values for other information like Label. However, to make the information consistent, I recommend that you should copy exactly everything.
After creating custom fields with the same ID as Pods, go to edit a post in the Project post type. If the custom fields look like what they were in Pods, everything is done.