我正在使用Redux框架创建一个自定义帖子类型。创建一个类别和该类别视图直接和直接转到链接,但该链接应直接转到404页。请检查下面的代码,让我知道我的代码中有什么错误。
remove_action( \'init\', \'brightness_service_register\',10 );
add_action( \'init\', \'brightness_service_register\',1 );
function brightness_service_register()
{
$labels = array(
\'name\' => __( \'Service\', \'brightness\' ),
\'add_new\' => __( \'Add New\', \'brightness\' ),
\'add_new_item\' => __( \'Add New Service\', \'brightness\'),
\'edit_item\' => __( \'Edit Service\', \'brightness\'),
\'new_item\' => __( \'New Service\', \'brightness\' ),
\'view_item\' => __( \'View Service\', \'brightness\' ),
\'search_items\' => __( \'Search Service\', \'brightness\' ),
\'not_found\' => __( \'No items found\', \'brightness\' ),
\'not_found_in_trash\' => __( \'No items found in Trash\', \'brightness\' ),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Service\'
);
$args = array(
\'labels\' => $labels,
\'menu_icon\' => \'dashicons-images-alt2\',
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'rewrite\' => array( \'slug\' => \'service\', \'with_front\' => false ),
\'exclude_from_search\' => true,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'page-attributes\' )
);
$taxonomy_labels = array(
\'name\' => __( \'Service Categories\', \'taxonomy general name\' ),
\'singular_name\' => __( \'Service Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Category\' ),
\'all_items\' => __( \'All Service Categories\' ),
\'parent_item\' => __( \'Parent Service Category\' ),
\'parent_item_colon\' => __( \'Parent Location:\' ),
\'edit_item\' => __( \'Edit Category\' ),
\'update_item\' => __( \'Update Category\' ),
\'add_new_item\' => __( \'Add New Category\' ),
\'new_item_name\' => __( \'New Category Name\' ),
\'menu_name\' => __( \'Service Categories\' ),
);
$taxonomy_args = array(
\'hierarchical\' => true,
\'labels\' => $taxonomy_labels,
\'rewrite\' => array(
\'slug\' => \'service-categories\', // This controls the base slug that will display before each term
\'with_front\' => false, // Don\'t display the category base before "/locations/"
\'hierarchical\' => true // This will allow URL\'s like "/locations/boston/cambridge/"
),
);
register_post_type( \'service\' , $args );
register_taxonomy(\'coll-categories\', \'service\',$taxonomy_args);
}