自定义帖子类型的自定义类别 [英] Custom category for custom post type

查看:45
本文介绍了自定义帖子类型的自定义类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 wordpress 主题中添加了自定义帖子类型.我与类别分类法相关,我可以与与帖子相同的类别相关联.我需要的是我的自定义帖子类型的自定义类别.

I added a custom post type to my wordpress theme. I related with category taxonomy, I can relate with the same categories as the posts. What I need is a custom category for my custom post type.

例如:帖子类型和书籍类别/虚构的书"

Eg: "book" for post type and book-category/fictional

我需要它与帖子类别不同.这可能吗?

I need it to be different than post categories. Is this possible?

推荐答案

是的,有可能!

http://codex.wordpress.org/Taxonomies

简而言之:

function register_book_genre_taxonomy() {
    register_taxonomy(
        'book_genre',
        'book',
        array(
            'label' => __( 'Genre' ),
            'rewrite' => array( 'slug' => 'genre' )
        )
    );
}

add_action( 'init', 'register_book_genre_taxonomy' );

这篇关于自定义帖子类型的自定义类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆