1
下面是代码:为什么我不能在类对象中添加register_post_type或taxonomy?
<?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);
}
}
}
?>
它不注册类型后因某种原因?但是当我在index.php中放入相同的register_post_type函数时,它工作正常
这是我确切的问题(回答工作)。为什么我每天都继续使用SO。 – orolo