Creating custom fields in WordPress usually means writing code or clicking through dozens of settings. But what if you could do it all by just typing a simple description? That’s now possible, exclusively with the compatibility of Meta Box and AI.
This could be a whole new approach that revolutionizes the way you build websites. In this blog post, we’ll explore the way to create a Meta Box field group using two of the most popular AI: ChatGPT and Cursor. This is an application of schema.
Video Version
Principle Behind Exclusive Compatibility of Meta Box-AI
AI (Artificial Intelligence) is becoming an essential part of various industries, including web creation. It makes building websites faster, smarter, and more accessible. The ability to process data and analyze user behavior enhances your experience and engagement rate.
Nowadays, many plugins integrate AI to improve user workflow. However, automatically creating custom fields just by writing a prompt for AI is a feature ONLY Meta Box offers. This is made possible thanks to Meta Box’s schema system and Local JSON.
For AI to understand and execute creating custom field commands, it needs a detailed schema, including all of the properties and attributes. Only Meta Box provides this kind of schema for AI tools to understand and generate valid code. Then, just describe each field in the field group, and AI tools will generate the corresponding code in a JSON file exactly.
After having the JSON file of the field group, just synchronize it to the database thanks to the local JSON feature. Then, your field group is already with the fields and settings you want.
With this feature, you don’t need to know code or even touch the MB Builder interface. Your work is simply typing the description (prompt). Now, let’s see how to create a field group using AI.
Create a Field Group Using ChatGPT
ChatGPT is an AI chatbot developed by OpenAI that understands and generates human-like text. It can answer questions, write content, and even help you generate code. So, instead of manually configuring each setting, you can simply describe your field group and let ChatGPT do the heavy lifting.
Generate Code for the Field Group
Go to ChatGPT.
Now, use the prompt “Create a field group for Meta Box” and specify the fields you need by answering these questions:
- What is the field group name?
- Which fields does the field group include?
- What are their names and field types?
- Do they have any special settings? What are they?
- Which post type is that field group applied to?
The more specific your description, the better the code you get — with less tweaking needed later.
Don’t forget the schema: https://schemas.metabox.io/field-group.json to ChatGPT following.
For example, I want to create a field group for the Event post type with 4 fields: Date, Location, Open Street Map, and Gallery. So, my prompt will be:
Create a field group for Meta Box plugin for WordPress, for the "event" post type, that has the following fields:
- Date: Type "datetime"
- Location: Type "text"
- Open Street Maps: Type " Osm", which refers to the Location field as "address"
- Gallery: Type "image_advanced"
Use the following schema: https://schemas.metabox.io/field-group.json
Then, a Meta Box field group configuration will be generated following the schema system. It’s the same as registering a field group using code.
In the case that you do not request the field group name, it’s created automatically based on the post type. For instance, the field group is created for the event
post type, so it’s Event Details.
Next, go to a code editor, create a mb.json
folder in your theme and paste that code into a new file. That’s a JSON file.
Sync Field Group to Database
Thanks to local JSON, you can easily sync the created JSON file to the database to have UI with just one click.
Go to Meta Box > Custom Fields and move to the Sync Available tab. Your field group is there. Then, click on the Sync quick button in the Status column to have an interface of that field group.
Now, go to the All tab, you can see the fields along with their settings and the location of the field group are exact.
They work well in the post editor.
No code, no clicking through any settings. Just type, copy, and go.
Create a Field Group Using Cursor
Cursor is an AI code editor to help developers write and edit code faster. With Cursor, you can write natural language prompts, and the AI will generate the corresponding code for you. Cursor Free is fully capable of handling the task of creating a Meta Box field group.
The Cursor interface consists of two main sections: The first section is similar to a code editor like VS Code, with a full folder structure. The second section is where you type your commands, and the Cursor responds with the generated results.
So, with Cursor, there's no need to manually copy code into your theme; just set the right file path. Let’s look at it in detail.
Generate Code for the Field Group
In the chat area, enter the prompt to create the field group you want. Describe it as using ChatGPT.
Notable that in the prompt, you should define the path of the file:
Create a field group for Meta Box plugin for WordPress in the folder wp-content/themes/twentytwentyfive/mb-json/event-details.json, for the "event" post type, that has the following fields:
- Date: Type "datetime"
- Location: Type "text"
- Open Street Maps: Type " Osm", which refers to the Location field as "address"
- Gallery: Type "image_advanced"
Use the following schema: https://schemas.metabox.io/field-group.json
Then, Cursor will analyze, process, and create a new file automatically, along with generating code for the file group.
Simply click on the Accept button to have a JSON file of the field group officially.
Sync Field Group to Database
Do the same with ChatGPT, also use the local JSON feature.
Last Words
Not only ChatGPT or Cursor, you can use any AI tool in the free version to create a Meta Box field group. No need for coding expertise or a settings-heavy interface, just type your field requirements and let the AI handle the rest.
This is just the beginning of our journey to bring AI closer to Meta Box users. You're not only embracing cutting-edge technology but also saving valuable development time and streamlining your workflow. The future of WordPress customization is here, and it starts with Meta Box.
Are you ready to try it out? Open your favorite AI tool and start building your first field group with a single prompt. If you have any ideas about AI, feel free to share them in the comments.