这是代码:
<?php
// (wp_plugin_dir/My_plugin/index.php)
class interface{
__construct(){
$this->get_commerce();
}
}
$interface = new interface();
// (wp_plugin_dir/My_plugin/commerce/commerce.php)
class commerce{
__construct(){
$this->register_post_types();
}
function register_post_types(){
$args = array( 'public' => true, 'label' => 'Books' );
register_post_type( 'book', $args );
}
}
}
?>
由于某种原因它没有注册帖子类型?但是当我将相同的 register_post_type 函数放入 index.php 时,它工作正常