Custom fields enables you to store specific information related to your content beyond the default fields. in practice, custom fields can be used to add various types of data, such as text, numbers, images, and dates, which enhances your content. for instance, you could create a fields for an author’s name, publication date, or product specifications, thereby structuring the information associated with your posts.
Creating Metabox
A metabox is a way to organize your fields, and it’s different from field groups. You can think of a field group as a larger box that holds all the metaboxes. Each metabox is used to group the individual fields inside it. So, field groups provide the overall structure, while metaboxes help organize the specific fields within that structure, you can have as many metaboxes as you want inside a field group.
To add a metabox, click on the “Add Meta Box” button. This screen will only appear if you’re creating your first metabox. If you’ve already created one, simply navigate to the top right corner of the screen and locate the button labeled “Add Meta Box.”
Once you’ve added the metabox, it’s important to give it a title. This title will be used when dynamically querying the fields on the frontend, so choose a title that is meaningful and easy to identify. This way, you’ll be able to easily distinguish between different metaboxes.
After you’ve named your metabox, proceed by clicking on the “Add Field” button. This action will create your first custom field.
Available Field Types in ACPT
ACPT offers a wide variety of field types that you can select based on the data you wish to store. Below is a list of the available field types in ACPT as of the current version, 2.0.16.
- Editor
- Number
- Range
- Text
- Textarea
- List
- HTML
- Select
- Select (Multiple)
- Toggle
- Checkbox
- Radio
- Table
- Country
- Date
- DateTime
- DateRange
- Time
- Url
- Phone
- Address
- Address (Multiple)
- Color
- Icon
- Rating
- Currency
- Weight
- Length
- Embed
- File
- Gallery
- Image
- Video
- Repeater
- Flexible
- Relationship
- Post
- Post(Multiple)
- Term
- Term (Multiple)
- User
- User (Multiple)
Custom Fields
Before diving into the creation of custom fields, take a moment to consider the data you’ll be collecting. This step is important as it determines the types of fields you’ll choose, ensuring they align perfectly with the data you plan to store.
To begin adding your first field, simply click on the ‘Add Field’ box.
This action will insert your initial field, which by default is set to a text type. However, you have the flexibility to change this depending on the type of data you wish to store.
Field Label is the label that will appear within the backend editor. It acts as an identifier to make it simpler for you to locate and recognize the field during the editing process.
Every field must have its own special slug, similar to a post. The ACPT makes this easy by creating the slug for you from the field label. If you want ACPT to do this, make sure ‘Auto Slug’ is turned on. If you’d rather make your own slug, just click the ‘Auto Slug On’ button, and it will change to ‘Auto Slug Off’.
Lastly, you’ll need to select the field type based on the type of data you plan to store in it.
For a deeper dive into the other tabs and settings, I suggest reading the ACPT Custom Field Settings Explained tutorial.