假设我们的分类法叫product
如果我们在加载完分类法之后,就做操作,可使用hook
add_action('registered_taxonomy', array($this,'on_taxonomy_registed'),10,3) ;
function on_taxonomy_registed($taxonomy, $object_type, $args){
if('product' == $taxonomy){
//操作
}
}
添加分类的方法
wp_insert_term('CMS系统', 'product' , array(
'description' => '',
'slug' => 'cms',
'parent' => 0,
)
);
查询分类法下的分类
$terms = get_terms( array(
'taxonomy' => 'product',
'hide_empty' => false,
));
暂无评论
要发表评论,您必须先 登录