diff --git a/packages/editor-tools/schema/post-type.schema.json b/packages/editor-tools/schema/post-type.schema.json index d009a62..9f3b8c0 100644 --- a/packages/editor-tools/schema/post-type.schema.json +++ b/packages/editor-tools/schema/post-type.schema.json @@ -461,6 +461,15 @@ "^[a-zA-Z0-9_]+$": { "type": "object", "properties": { + "post_types": { + "type": "array", + "description": "An array of post type identifiers that will be registered for the taxonomy. Post types can be registered later with register_post_type() or register_post_type_for_object_type().", + "items": { + "type": "string", + "pattern": "^[a-zA-Z0-9_]+$", + "description": "Post type identifier" + } + }, "labels": { "type": "object", "description": "An array of labels for this taxonomy. If not set, taxonomy labels are inherited from post type labels. See [get_taxonomy_labels()](https://developer.wordpress.org/reference/functions/get_taxonomy_labels/) for a full list of supported labels.", diff --git a/packages/editor-tools/src/PostTypes.php b/packages/editor-tools/src/PostTypes.php index d80e696..4c81159 100644 --- a/packages/editor-tools/src/PostTypes.php +++ b/packages/editor-tools/src/PostTypes.php @@ -42,7 +42,7 @@ public function register_post_types(): void { } foreach ( $data['taxonomies'] ?? array() as $name => $args ) { - register_taxonomy( $name, array(), $args ); + register_taxonomy( $name, $args['post_types'] ?? 'post', $args ); } foreach ( $data['post_types'] ?? array() as $name => $args ) { diff --git a/packages/editor-tools/tests/TestPostTypes.php b/packages/editor-tools/tests/TestPostTypes.php index 824f446..8c20e99 100644 --- a/packages/editor-tools/tests/TestPostTypes.php +++ b/packages/editor-tools/tests/TestPostTypes.php @@ -73,7 +73,7 @@ public function testRegisterPostTypes(): void { ->once() ->with( 'example_category', - array(), + 'post', array( 'labels' => array( 'name' => 'TestName',