我们的一个块已经停止工作,我知道这可能是因为“post\\u taxs\\u obj”没有包含在PHP register\\u block\\u类型属性中,但我不知道如何解决这个问题-请任何人提出建议?(我不是开发人员,只是想加入并修复此问题,因此非常感谢您的帮助):
错误:
{"code":"rest_invalid_param","message":"Invalid parameter(s): attributes","data":{"status":400,"params":{"attributes":"post_taxs_obj is not a valid property of Object."},"details":{"attributes":{"code":"rest_additional_properties_forbidden","message":"post_taxs_obj is not a valid property of Object.","data":null}}}}
以下是PHP:
register_block_type( \'performancein/article-listing\',
array(
\'render_callback\' => \'performancein_article_listing_callback\',
\'attributes\' => [
\'post_type\' => [
\'default\' => \'\',
\'type\' => \'string\'
],
\'post_taxs\' => [
\'default\' => \'\',
\'type\' => \'string\'
],
\'post_category\' => [
\'default\' => \'\',
\'type\' => \'string\'
],
\'number_of_post\' => [
\'default\' => \'0\',
\'type\' => \'number\'
],
\'category_description\' => [
\'default\' => false,
\'type\' => \'bool\'
],
\'exclude_post\' => [
\'default\' => \'\',
\'type\' => \'string\'
],
]
)
);
和JS:
registerBlockType(\'performancein/article-listing\', {
title: \'Article Listing\',
icon: ArticleIcon,
category: \'performancein\',
keywords: [__(\'ArticleFilter\'), __(\'gutenberg\'), __(\'performancein\')],
description: __( \'It showcase article listing \' ),
example: {
attributes: {
caption: __( \'Article Listing\' ),
},
},
attributes: {
number_of_post: {
type: \'number\',
default: \'0\',
},
post_type: {
default: \'\',
type: \'string\',
},
post_type_obj: {
type: \'json\',
},
post_taxs: {
default: \'\',
type: \'string\',
},
post_taxs_obj: {
default: [{label: \'--Select Taxonomy--\', value: \'\'}],
type: \'json\',
},
post_category: {
default: \'\',
type: \'string\',
},
post_category_obj: {
default: [{label: \'--Select Category--\', value: \'\'}],
type: \'json\',
},
category_description: {
default: false,
type: \'boolean\',
},
exclude_post: {type: \'string\'},
design_option: {
type: \'string\',
default: \'\',
},
},
UPDATE
感谢修复Tom,解决方案只是按照他的指导,采用以下格式:
\'post_type_obj\' => [
\'default\' => \'\',
\'type\' => \'json\'
],