最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

404 error - Custom post type single page 404

programmeradmin2浏览0评论

I have read a lot similar questions, but none of them saves me.

The site have multi-custom post type registered, others are ok to load a single page, except one,

function cabinet_post_type(){
$labels = array(
    'name'                => __('Cabinets'),
    'singular_name'       => __('Cabinet'),
    'menu_name'           => __('Cabinets'),
);

$args = array(
    'description'         => __('Cabinets'),
    'labels'              => $labels,
    'supports'            => array('title', 'editor', 'thumbnail', 'revisions', 'genesis-seo', 'genesis-cpt-archives-settings'),
    'show_in_rest'        => true,
    'public'              => true,
    'hierarchical'        => false,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'query_var'           => true,
    'menu_icon'           => 'dashicons-editor-ul',
    'has_archive'         => true,
    'can_export'          => true,
    'exclude_from_search' => false,
    'yarpp_support'       => true,
    'publicly_queryable'  => true,
    'capability_type'     => 'page'
);

register_post_type('cabinet', $args);}

I have no cue how that happens, could any big boss figure that out? so many thanks

I have read a lot similar questions, but none of them saves me.

The site have multi-custom post type registered, others are ok to load a single page, except one,

function cabinet_post_type(){
$labels = array(
    'name'                => __('Cabinets'),
    'singular_name'       => __('Cabinet'),
    'menu_name'           => __('Cabinets'),
);

$args = array(
    'description'         => __('Cabinets'),
    'labels'              => $labels,
    'supports'            => array('title', 'editor', 'thumbnail', 'revisions', 'genesis-seo', 'genesis-cpt-archives-settings'),
    'show_in_rest'        => true,
    'public'              => true,
    'hierarchical'        => false,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'query_var'           => true,
    'menu_icon'           => 'dashicons-editor-ul',
    'has_archive'         => true,
    'can_export'          => true,
    'exclude_from_search' => false,
    'yarpp_support'       => true,
    'publicly_queryable'  => true,
    'capability_type'     => 'page'
);

register_post_type('cabinet', $args);}

I have no cue how that happens, could any big boss figure that out? so many thanks

Share Improve this question asked Nov 13, 2020 at 16:24 Hao PhungHao Phung 1 2
  • Visiti permalinks to flush them. – vancoder Commented Nov 13, 2020 at 16:42
  • As @vancoder said you can flush permalinks - Settings > Permalinks > Save – Bysander Commented Nov 23, 2020 at 16:52
Add a comment  | 

1 Answer 1

Reset to default 0

After a long search! I found a simple answer on a similar case. just add this line in the custom post type register

"taxonomies" => [ "category", "product-category" ],

then it will do the magic!

发布评论

评论列表(0)

  1. 暂无评论