我正在wordpress站点上构建FAQ部分。我有一个称为faq的自定义发布类型,并且有一个名为faq-category的自定义分类。我还在使用名为Custom Post Type Permalinks
的插件。Wordpress自定义帖子和分类标签404
我试图实现以下固定链接结构:
- domain.com/faq
- domain.com/faq/category
- domain.com/faq/category/question-title
到目前为止,我似乎只能得到2/3的工作。所以下面的例子给我:
- domain.com/faq
- domain.com/faq/category
和`domain.com/faq/category/question-title一个404
如果我更改:'slug' => 'faq'
到'slug' => ''
关于我重新编写的自定义分类。我在分类页面上得到了404
错误,并且单个帖子将工作。
感谢
/**
* Custom taxonomys
*/
function create_faq_tax() {
register_taxonomy(
'faq-category',
'faq',
array(
'label' => __('Category'),
'rewrite' => array('slug' => 'faq', 'with_front' => false, 'hierarchical' => true),
'hierarchical' => true
)
);
}
add_action('init', 'create_faq_tax');
/**
* FAQ Custom post type
*/
function create_faq_post_type() {
register_post_type('faq',
array(
'labels' => array(
'name' => __('FAQ\'s'),
'singular_name' => __('FAQ'),
'add_new' => 'Add new FAQ',
'add_new_item' => 'Add a new FAQ',
'edit_item' => 'Edit FAQ',
),
'public' => true,
'publicly_queryable' => true,
'hierarchical' => true,
'taxonomies' => array('faq-category'),
'has_archive' => true,
'menu_icon' => 'dashicons-feedback',
'rewrite' => array('slug' => 'faq', 'with_front' => false),
'query_var' => true,
)
);
}
add_action('init', 'create_faq_post_type');
我遇到了与我自己的自定义帖子类型(啤酒)和类似的分类(啤酒/风格)相同的问题。如果我将slug设置为'beer/style',它会抛出一个404,但是如果我将slug设置为'style',那么纳税页就可以工作,尽管不在我期望的永久链接结构中。 – Quantastical