自定义帖子类型单页404

时间:2020-11-13 作者:Hao Phung

我读过很多类似的问题,但都救不了我。

该网站注册了多个自定义帖子类型,其他人可以加载一个页面,除了一个,

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);}
我不知道这是怎么回事,任何大老板都知道吗?非常感谢

1 个回复
SO网友:Hao Phung

经过长时间的搜索!我在一个类似的案例中找到了一个简单的答案。只需在自定义post类型寄存器中添加此行

"taxonomies" => [ "category", "product-category" ],
然后它会变魔术!