Home » Custom Posts and Fields » Defining Fields

Defining Fields

This guide explains how to define fields in QuickBuildWP when creating field groups. It covers standard post fields, field options, and validation rules.


1. Standard Post Fields

When creating posts, these standard fields have fixed rules, labels, and settings that cannot be modified. Use them as needed in your custom post type:
Field Name Description
post_title Post Title
post_slug Post Slug (URL)
post_editor Content Editor
post_excerpt Post Excerpt
post_trackbacks Trackbacks
post_custom_fields Custom Fields
post_comments Comments Section
post_revisions Post Revisions
post_thumbnail Featured Image
post_author Post Author
Example: To enable the Title field, set the field name as post_title.

2. Defining Fields

When defining fields, ensure each field has a unique name and relevant settings.

Field Options Available:

A. Type

  • Select the type of input for your custom field.
  • Example: Use TEXT for a standard text input.

B. Meta Box

  • Choose the meta box where this field will be displayed.

C. Label

  • The label is displayed for the field in the admin panel.

D. Name

  • The database field name. Each field is stored with a prefix _qb_. This prefix is hardcoded in the plugin.
  • Example: If the field name is contact_person, it is stored as _qb_contact_person.

E. Priority

  • Set the field's display order.
  • Lower priority fields are displayed at the top.

3. Field Validation Rules

Enable the following validation rules to ensure secure and proper data entry:

Available Rules:

Rule Description
Trim Restores the field value on validation error
Required Marks the field as mandatory
Is Array Allows multiple values using an array
Sanitize Filters harmful input to prevent XSS
Additional Validation Rules:
  • is_numeric – Validates numeric values.
  • is_decimal – Checks for decimal numbers.
  • alpha – Accepts only letters.
  • alpha_extra – Letters with extra symbols.
  • alpha_numeric – Letters and numbers.
  • alpha_dash – Letters, numbers, dashes, and underscores.
  • valid_email – Checks for valid email addresses.
  • valid_url – Validates URLs.
  • phone_check – Ensures a valid phone number.
  • valid_ip – Checks for valid IP addresses.
  • valid_date – Validates date format.
  • valid_date_future – Ensures future date entry.
  • valid_time – Validates time format.
  • valid_datetime – Ensures date and time correctness.
  • valid_datetime_future – Ensures future date and time.
  • sanitize_text – Cleans text input.

4. Custom Field Options

Each field type supports specific settings, which can be configured using JSON format in the Options field.

Example:

To set a limit of 1 for an image_uploader field, use:
{"limit": 1}

By following this guide, you can define fields for your field group in QuickBuildWP, ensuring organized data entry, validation, and enhanced post management.