Meta fields and meta boxes

GD Content Tools Pro implements meta fields and meta boxes for allowing users to easily add additional data to posts (any post type), terms (any taxonomy) and users (for any user role).

Base Fields

Base fields are basic building blocks for meta fields. The plugin supports 30+ base fields. These fields are used to implement data specific controls for text, numbers, selection lists, images and more. Each basic field can have own settings specific to the field type. And, most base fields can be used as repeaters. Some base fields don’t have additional settings (image, file, …).

Simple Field Example
Simple Field Example

Meta Fields

Meta Fields panel is used to add and manage fields. The plugin supports two types of fields: Simple and Custom.

Simple Field

This field type is basically a wrapper for a single base field. The custom field is a container that can hold one or more base fields. The image on the right shows the editor for a simple meta field. As you can see, it uses color codes for marking different elements of the field.

  • Blue – required elements for label and slug, and an optional description. Each field should have a different slug because slug is used to identify data in the database.
  • Purple – settings for required field and repeater.
  • Orange – select the type of the field. This selection shows a list of all available base fields. Once you change the selected field, second below will change to show options specific to the selected base field.
  • Green – settings for the selected base field.
  • Yellow – additional settings, now including CSS classes used for rendering administration side meta box.

It is important to note that some base fields might not support the use of repeaters or set the field as required. If you try to use these options with some field types, the plugin will disable these options on save.

Custom Field Example
Custom Field Example

Some base fields will include options for default value or placeholder, but not every field type does.

Custom Field

This field used to make more complex data structures that can’t be described with base/simple field only. Each base field inside the custom field can be used as a repeater, and the whole custom field can be a repeater also.

The second image shows the editor for the Custom Field. This field has two main elements. The top part shows all the settings simple field has with the exception of the field type. The custom field can contain multiple base fields, and you can add and edit these base fields in the lower part of this form.

Editor for each base field is the same as with the simple field. The main difference is that you can use additional buttons to remove individual fields or move the up and down the order. Each field header has an option to collapse the field display. Collapsed field can be moved using drag and drop to reorder.

If the base fields inside custom field are set as repeaters, these fields can be repeated inside the custom field. The whole custom field can be set as repeater too. Same goes for the required field. But, if you send base field as required, the whole custom field will behave as required by default.

Meta Boxes

Meta box is a wrapper for one or more meta fields. The plugin has two types of meta boxes, that are virtually identical. The only difference between Meta Box and Legacy Box is the format for saving metadata into the database.

Legacy Box

The legacy box is created for the purpose of compatibility with old GD Custom Posts and Taxonomies Tools Pro plugin to allow for the old way of saving data. If you transfer meta boxes from the old plugin, you will be using the Legacy box for those meta boxes. If you create new boxes, it is recommended to use Meta Box. Legacy meta box can’t use Custom Fields, it is limited to Simple Fields only (again due to compatibility with old plugin).

Meta Box Setup

Setting up the meta box is the same for Meta Box or Legacy Box. The image below shows the typical meta box interface. It has 3 blocks.

The first block describes the meta box. Label and slug are required, and it is important to have a unique slug for each meta box, it is used to store data in the database later. Metabox layout has options to set the field location and description location inside the field.

Integration block is used to assign the meta box to different post types, taxonomies and user roles. For posts, you can choose the location and priority for the metabox. In other cases, the box will be rendered according to the creation time of the metabox. Each meta box can be assigned to multiple post type taxonomy or user role.

The final block is for adding fields into meta box. Each field has an option to start the tab. All fields from that point on will be placed in that tab. You can create a new tab for fields bellow, and they will be placed in the tabs. Fields on top can be displayed on top, outside the tabbed interface.

Meta Box Example
Meta Box Example
0
0
279
Rate this article

You are not allowed to rate this post.

Comments

Leave a Reply