wordpress分类增查

假设我们的分类法叫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,
            ));

暂无评论

相关推荐

微信扫一扫,分享到朋友圈

wordpress分类增查