我已经创建了一个自定义post类型并扩展了文档中的WP\\u JSON\\u CustomPostType类,当我转到WP-JSON/时,我可以看到自定义类型,但只要我转到WP-JSON/就会发现这个错误,任何帮助都会很好。PS:我是插件开发新手。
register_post_type(\'quiz\',
array(
\'labels\' => array(
\'name\' => __( \'Quizes\' ),
\'singular_name\' => __(\'Quiz\'),
),
\'public\' => true,
\'has_archive\' =>true,
\'show_ui\' =>true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'hierarchical\' => false,
\'capability_type\' => \'post\',
)
);
public function quizno_api_init($server)
{
global $quizno_api_quiz;
$quizno_api_quiz = new QN_API_Quiz($server);
$quizno_api_quiz->register_filters();
}
/**
* wp-api extension
*/
class QN_API_Quiz extends WP_JSON_CustomPostType
{
protected $base = \'quizes\';
protected $type = \'quiz\';
public function register_routes($routes)
{
$routes = parent::register_routes($routes);
return $routes;
}
}