admin管理员组文章数量:1387346
I am creating a Wordpress Custom Post Type including a taxonomy, after installing, all permalinks where flushed, however the taxonomy archive page is constantly giving me 404.
The CPT archive page works perfectly fine.
Code to create:
add_action( 'init', 'register_cpt_post_type' );
function register_cpt_post_type() {
register_post_type( 'offers',
array(
'labels' => array(
'name' => 'Offer Posts',
'menu_name' => 'Offers Manager',
'singular_name' => 'Offer post',
'all_items' => 'All Offers Posts'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ),
'hierarchical' => false,
'has_archive' => 'offers',
'show_in_rest' => true,
'taxonomies' => array('offers-category')
)
);
register_taxonomy( 'offers-category', array( 'offers' ),
array(
'labels' => array(
'name' => 'Offer Categories',
'menu_name' => 'Offer Categories',
'singular_name' => 'Offers Category',
'all_items' => 'All Categories'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_rest' => true,
'rewrite'=>array( 'slug'=>'offers' )
)
);
}
If I try access www.xxx/offers -> that works perfectly fine and gives me the archive page template
If I try access www.xxx/offers/food -> Where food is a category created, page leads to 404.
Can you some please guide me if I am setting up something wrong?
I am creating a Wordpress Custom Post Type including a taxonomy, after installing, all permalinks where flushed, however the taxonomy archive page is constantly giving me 404.
The CPT archive page works perfectly fine.
Code to create:
add_action( 'init', 'register_cpt_post_type' );
function register_cpt_post_type() {
register_post_type( 'offers',
array(
'labels' => array(
'name' => 'Offer Posts',
'menu_name' => 'Offers Manager',
'singular_name' => 'Offer post',
'all_items' => 'All Offers Posts'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'comments', 'post-formats', 'revisions' ),
'hierarchical' => false,
'has_archive' => 'offers',
'show_in_rest' => true,
'taxonomies' => array('offers-category')
)
);
register_taxonomy( 'offers-category', array( 'offers' ),
array(
'labels' => array(
'name' => 'Offer Categories',
'menu_name' => 'Offer Categories',
'singular_name' => 'Offers Category',
'all_items' => 'All Categories'
),
'public' => true,
'hierarchical' => true,
'show_ui' => true,
'show_in_rest' => true,
'rewrite'=>array( 'slug'=>'offers' )
)
);
}
If I try access www.xxx/offers -> that works perfectly fine and gives me the archive page template
If I try access www.xxx/offers/food -> Where food is a category created, page leads to 404.
Can you some please guide me if I am setting up something wrong?
Share Improve this question asked Apr 17, 2020 at 8:29 JBolJBol 1 2- You did Permalink Change in your admin setting – HK89 Commented Apr 17, 2020 at 9:04
- @HK89 - Yes I have flushed the permalinks several times already – JBol Commented Apr 17, 2020 at 9:28
1 Answer
Reset to default 0The taxonomy is using the same slug as your custom post type. Try to rewrite the custom taxonomy or custom post type slug with different names if possible or try the solution suggested here: Add category base to url in custom post type/taxonomy
本文标签: custom post types404Taxonomy Archive Page
版权声明:本文标题:custom post types - 404 - Taxonomy Archive Page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744557332a2612555.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论