- Article
- 4 minutes read
- Reviewed August 3, 2026
Custom fields store additional information about a WordPress content object. In technical terms, post custom fields are entries in the post metadata system.
They allow a content type to capture values that do not belong in the title or main editor, such as an event date, product reference, duration, price or featured status.
Custom Fields and Metadata
The administration interface often uses the phrase custom field, while WordPress APIs use the broader term metadata. Metadata associates a key and value with an object ID.
WordPress provides metadata APIs for posts, terms, users and comments. This article focuses on post metadata used by posts, pages and custom post types.
What Belongs in a Custom Field?
A custom field is appropriate when a value has a defined meaning and needs consistent storage, validation, querying, reuse or presentation.
- Event start date and time.
- Property price and floor area.
- Course duration and difficulty.
- External system identifier.
- Boolean status such as featured or archived.
- Relationship to another content record.
Long-form narrative content usually remains in the editor. Splitting every sentence into fields can create an inflexible and exhausting form.
Metadata Keys
A metadata key is the technical name used to save and retrieve a value. Keys should be stable, namespaced and documented.
Changing a key after publication requires migrating existing values and updating templates, queries, REST schemas, exports and integrations.
Value Types
Database metadata values are flexible, but applications should define the expected type: string, integer, number, boolean, array or object.
A date should also use a documented format. Mixing human-readable dates and timestamps in the same key makes sorting and integration unreliable.
Registering Metadata
Important metadata can be registered with WordPress. Registration defines details such as type, default value, sanitization, authorization and REST visibility.
register_post_meta( 'event', 'event_start', array(
'type' => 'string',
'single' => true,
'show_in_rest' => true,
'sanitize_callback' => 'sanitize_text_field',
'auth_callback' => function () {
return current_user_can( 'edit_posts' );
},
) );
For block-editor and REST use, the post type generally needs custom-fields support and the meta field must be exposed appropriately.
Single and Multiple Values
A metadata key can have one value or several rows. A single setting such as event start date should usually be treated as a single value.
Multiple values under one key can be useful, but repeated or relational data often needs a clearer schema and editing interface.
Querying Metadata
WordPress can filter and sort content by metadata. This is useful for modest datasets, but complex meta queries can become expensive because the database was not designed as a strongly typed analytical store.
Store queryable values consistently, use appropriate indexes where architecture permits and avoid expecting arbitrary serialized arrays to perform like relational columns.
Security and Validation
User input should be validated against business rules and sanitized before storage. Output must be escaped for its destination, such as HTML text, attributes or URLs.
Authorization decides who may read or update a value. A visible field in an editor is not proof that a request is permitted.
Data Ownership
Custom fields often outlive the plugin that created their interface. Document keys, formats and deletion policies so another tool or migration can interpret the data.
Uninstall routines should not remove valuable content metadata without explicit consent.
Good Metadata Design
- Use one documented meaning per key.
- Choose stable, namespaced keys.
- Define type, format and default behaviour.
- Register important fields with WordPress.
- Validate, sanitize, authorize and escape correctly.
- Avoid serialized structures for values that must be queried independently.
- Document retention, export and migration rules.
Frequently Asked Questions
Are custom fields and post meta the same?
In common WordPress use, custom fields are values stored through the post metadata system. A custom field plugin may provide a richer interface and schema around that storage.
Can metadata be exposed through the REST API?
Yes. Register the metadata with appropriate type, permissions and show_in_rest settings, and ensure the post type supports the required features.
Should every custom field be searchable?
No. Only query values that support a real user or system requirement. Complex metadata queries can affect performance.