Guide

Taxonomy Abilities

Abilities for creating and updating custom taxonomies.


native-custom-fields/create-taxonomy

Creates a new custom taxonomy and saves its configuration.

native-custom-fields/update-taxonomy

Updates the configuration of an existing custom taxonomy.

Both abilities share the same execute_callback (saveTaxonomy) and the same input schema. If the taxonomy slug already exists, the record is updated; otherwise a new one is created.


Input Schema

{
  "type": "object",
  "required": ["taxonomy", "label", "object_type"]
}

Properties

PropertyRequiredTypeDefaultDescription
taxonomyYesstringTaxonomy slug (lowercase, max 32 chars)
labelYesstringPlural label (e.g. "Genres")
object_typeYesstring[]Post type slugs to attach this taxonomy to (e.g. ["post", "book"])
singular_nameNostringlabel valueSingular label (e.g. "Genre")
descriptionNostring""Description of the taxonomy
publicNobooleantrueWhether the taxonomy is publicly accessible
hierarchicalNobooleantruetrue for category-like (hierarchical), false for tag-like (flat)
show_admin_columnNobooleanfalseWhether to show a taxonomy column on the post type list screen
show_in_restNobooleantrueWhether to expose the taxonomy in the WordPress REST API

Output Schema

{
  "status": true,
  "message": "..."
}
FieldTypeDescription
statusbooleantrue on success, false on failure
messagestringResult description or error message

Internal Behaviour

  • taxonomy is sanitized with sanitize_key().
  • Each value in the object_type array is sanitized with sanitize_key().
  • Builder slug format: native_custom_fields_taxonomy_builder_{taxonomy}
  • On success, the same values are also stored via OptionService::saveOptions().
  • Label strings (add_new_item, all_items, search_items, etc.) are automatically generated from label and singular_name.

Auto-generated Visibility Settings

publicly_queryable:  true
show_ui:             true
show_in_menu:        true
show_tagcloud:       true
show_in_quick_edit:  true
show_in_nav_menus:   true
slug:         {taxonomy}
with_front:   true
hierarchical: {input.hierarchical}
ep_mask:      EP_NONE

Examples

Minimal

{
  "taxonomy": "genre",
  "label": "Genres",
  "object_type": ["book"]
}

Full

{
  "taxonomy": "genre",
  "label": "Genres",
  "singular_name": "Genre",
  "object_type": ["book", "post"],
  "description": "Taxonomy for book genres",
  "public": true,
  "hierarchical": true,
  "show_admin_column": true,
  "show_in_rest": true
}

Success Response

{
  "status": true,
  "message": "Taxonomy saved successfully."
}

Error Responses

{ "status": false, "message": "taxonomy is required." }
{ "status": false, "message": "label is required." }
{ "status": false, "message": "object_type is required." }

Permission

Requires the manage_options WordPress capability.

Was this helpful?