首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >自定义post类型类别的归档

自定义post类型类别的归档
EN

Stack Overflow用户
提问于 2015-01-10 00:46:16
回答 2查看 134关注 0票数 0

我创建了自定义post类型,并为自定义post类型创建了自定义类别。我能够显示每个自定义类别的帖子,但不能为每个类别显示存档。请帮助我获得每个自定义类别的存档。

自定义邮政类型-新闻类别-政治

www.website.com/news/ -存档正在运行

www.website.com/news/political -显示404错误。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-01-10 02:13:08

是的,通过将has_archive设置为true,您可以在那里添加档案。

代码语言:javascript
运行
复制
$args = array(
    'labels'             => $labels,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'book' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);

参考资料:type

票数 0
EN

Stack Overflow用户

发布于 2015-01-10 01:25:21

注册自定义分类法时是否有重写规则?

例如:

代码语言:javascript
运行
复制
register_taxonomy( 'taxonomy_name', 
    array('post_type_name'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
    array('hierarchical' => true,     /* if this is true, it acts like categories */             
        'labels' => array(
            //blah blah blah
        ),
        'show_admin_column' => true, 
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'custom-slug' ),
    )
); 

您可以尝试检查自定义分类法片段的实际url,方法是转到Post类型名称(如POST)、->、分类法名称(类似类别)>每个标题上的Hover并单击视图,

如果您仍然得到一个错误页面,尝试将您的permalinks重置为默认,然后再次检查,

如果仍然有错误页面,那么注册自定义类别的方式有问题

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

https://stackoverflow.com/questions/27871619

复制
相关文章

相似问题

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