首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用相同鼻塞的自定义分类法标记和类别

使用相同鼻塞的自定义分类法标记和类别
EN

WordPress Development用户
提问于 2018-08-09 21:31:37
回答 1查看 322关注 0票数 -1

我似乎在使用与register_taxonomy _category和_tag相同的“弹子”出版物时遇到了问题。似乎只有最后一次调用register_taxonomy('publications_tag',才能使用这种弹格。与前面的调用一样,register_taxonomy('publications_category',呈现一个404。

我如何才能对类别和标记使用相同的段塞,然后我假设它将使用我的分类法-{post_..php模板?

//自定义邮政类型:

代码语言:javascript
复制
register_post_type( 'publications', $args );

    $args = array(
    'label'                 => __( 'Publication', 'text_domain' ),
    'description'           => __( 'Publications', 'text_domain' ),
    'labels'                => $labels,
    'supports'              => array(
        'title',
        'editor',
        'thumbnail',
        'excerpt',
        'revisions',
        'author',
        'post-formats',
        //'comments',
        'page-attributes'
        ),
    'taxonomies'            => array(
        'publications_category',
        'publications_tag'
        ),
    'hierarchical'          => false,
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 20,
    'menu_icon'             => 'dashicons-align-left',
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => 'publications',
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'capability_type'       => 'post',
    'show_in_rest'          => true,
    'rewrite'                           => array(
    //  'slug' => 'publications',
        'with_front' => false
        ),
);

//类别:

代码语言:javascript
复制
register_taxonomy('publications_category', 'publications', array (
    'labels' => array (
    //
    ),
        'hierarchical' => true,
        'show_ui' => true,
        'show_tagcloud' => true,
        'rewrite' => array(
            'slug' => 'publications',
            'with_front' => false ),
        'public' => true
        )
);

//标签:

代码语言:javascript
复制
register_taxonomy('publications_tag','publications', array(
    'labels' => array (
    //
    ),
        'hierarchical' => false,
        'rewrite' => array(
            'slug' => 'publications',
            'with_front' => false ),
        )
    );
EN

回答 1

WordPress Development用户

回答已采纳

发布于 2018-08-10 10:45:44

因此,我为重写段塞添加了/标记/类别,而不是添加publicationspublications/%publications_tag%。我最初认为这两种分类法类型都可以存在于父post类型中,wordpress可以解决其余的问题。

标签:'rewrite' => array( 'slug' => 'publication/tag', 'with_front' => false ),

类似于:domain.test/publications/tag/example-tag/和use是axonomy-publications_tag.php文件。

类别:'rewrite' => array( 'slug' => 'publication/category', 'with_front' => false ),看起来像:domain.test/publications/category/example-category/和use的axonomy-publications_category.php文件。

票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/310994

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档