我创建了自定义post类型,并为自定义post类型创建了自定义类别。我能够显示每个自定义类别的帖子,但不能为每个类别显示存档。请帮助我获得每个自定义类别的存档。
自定义邮政类型-新闻类别-政治
www.website.com/news/ -存档正在运行
www.website.com/news/political -显示404错误。
发布于 2015-01-10 02:13:08
是的,通过将has_archive设置为true,您可以在那里添加档案。
$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
发布于 2015-01-10 01:25:21
注册自定义分类法时是否有重写规则?
例如:
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重置为默认,然后再次检查,
如果仍然有错误页面,那么注册自定义类别的方式有问题
https://stackoverflow.com/questions/27871619
复制相似问题