[英]How to solve "wordpress custom taxonomy 404 error"?
我有自定义帖子类型“优惠券”:
$args = array(
'label' => __('Купоны', 'sp'),
'labels' => $labels,
'supports' => array('title', 'custom-fields', 'revisions', 'thumbnail', 'excerpt'),
'hierarchical' => true,
'public' => false,
'show_ui' => true,
'menu_position' => 2,
'show_in_admin_bar' => true,
'has_archive' => true,
'capability_type' => 'post',
'rewrite' => array('slug' => 'coupons', 'with_front' => false)
);
register_post_type('coupons', $args);
我有自定义分类“类别”:
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array(
'slug' => 'sategory',
'with_front' => false),
);
register_taxonomy('sategory', array('coupons'), $args);
当我打开“example.com/sategory/tax1”时出现 404 错误。 文件 taxonomy-sategory.php 创建。 可能是什么问题呢?
要扩展@KrunalBhimajiyani 所说的内容,无论何时创建 CPT 或分类法,或以 URL 结构会改变的方式编辑它们,您都需要“刷新永久链接”。
出于性能原因,URL 映射代码被缓存并且不会更改,除非管理员手动更新它。 这可以通过执行以下任何一项来完成:
flush_rewrite_rules
(并非总是如此。您需要在完成后将其删除,或者在选项中存储版本密钥或类似内容。)wp rewrite flush
(可选地使用--hard
参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.