【问题标题】:Custom category for custom post type自定义帖子类型的自定义类别
【发布时间】:2014-08-04 21:10:01
【问题描述】:

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

例如:帖子类型和书籍类别/小说的“书籍”

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

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    是的,先生,这是可能的!

    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' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-24
      • 2013-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-02
      • 1970-01-01
      相关资源
      最近更新 更多