WordPress中出现404错误的自定义帖子类型

WordPress中出现404错误的自定义帖子类型,wordpress,Wordpress,我创建了一个插件,为我正在构建的网站创建自定义帖子类型。当我点击永久链接时,我得到一个404错误。我的代码如下所示 //////// Create Rates Custom Post function rate_groupings_custom_post() { $labels = array( 'name' => _x( 'Rate Groups', 'post type general name' ), 'singular_name'

我创建了一个插件,为我正在构建的网站创建自定义帖子类型。当我点击永久链接时,我得到一个404错误。我的代码如下所示

//////// Create Rates Custom Post
function rate_groupings_custom_post() {
$labels = array(
    'name'               => _x( 'Rate Groups', 'post type general name' ),
    'singular_name'      => _x( 'Rate Group', 'post type singular name' ),
    'add_new'            => _x( 'Add New Group', 'Group' ),
    'add_new_item'       => __( 'Add New Group' ),
    'edit_item'          => __( 'Edit Group' ),
    'new_item'           => __( 'New Group' ),
    'all_items'          => __( 'All Groups' ),
    'view_item'          => __( 'View Group' ),
    'search_items'       => __( 'Search Groups' ),
    'not_found'          => __( 'No Groups found' ),
    'not_found_in_trash' => __( 'No Groups found in the Trash' ),
    'parent_item_colon'  => '',
    'menu_name'          => 'Rate Groups'
);
$args = array(
    'labels'        => $labels,
    'description'   => 'Menu area to add Group',
    'public'        => true,
    'publicly_queryable' => true,
    'menu_position' => 35,
    'menu_icon'     => 'dashicons-admin-multisite',
    'supports'      => array( 'title', 'thumbnail', 'page-attributes', 'editor' ),
    'has_archive'   => false,
    'show_in_rest' => false
);

register_post_type( 'rates', $args );
}
add_action( 'init', 'rate_groupings_custom_post' );

通常情况下,当你的网站出现404错误时,这与你的代码无关,比如说,只是链接指向了错误的地方,或者你的永久链接配置不正确

尝试在面板的设置中查看permalink,并验证创建的路径是否正确

如果您有进一步的疑问,WP初学者可以帮助您:


祝你好运:)

每当我构建自定义帖子类型时,我总是刷新重写规则:


在左侧的侧栏菜单中,进入设置>永久链接,然后单击保存更改。

尝试设置=>永久链接=>单击保存更改