我创建了一个自定义帖子,其中包含一个自定义类别,如下所示
function fitters() {
$labels = array(
\'name\' => _x( \'Fitters\', \'Post Type General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Fitter\', \'Post Type Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Fitters\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Item:\', \'text_domain\' ),
\'all_items\' => __( \'All Fitters\', \'text_domain\' ),
\'view_item\' => __( \'View Fitter\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Fitter\', \'text_domain\' ),
\'add_new\' => __( \'Add New\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Fitter\', \'text_domain\' ),
\'update_item\' => __( \'Update Fitter\', \'text_domain\' ),
\'search_items\' => __( \'Search Fitters\', \'text_domain\' ),
\'not_found\' => __( \'Not found\', \'text_domain\' ),
\'not_found_in_trash\' => __( \'Not found in Trash\', \'text_domain\' ),
);
$args = array(
\'label\' => __( \'fitter\', \'text_domain\' ),
\'description\' => __( \'Post Type Description\', \'text_domain\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', ),
\'taxonomies\' => array( \'fitter_categories\', \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 5,
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
\'menu_icon\' => \'dashicons-businessman\',
);
register_post_type( \'fitter\', $args );
}
function fitter_taxonomy() {
register_taxonomy(
\'fitter_categories\', //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
\'fitter\', //post type name
array(
\'hierarchical\' => true,
\'label\' => \'Fitter States\', //Display name
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'fitter\', // This controls the base slug that will display before each term
\'with_front\' => false // Don\'t display the category base before
)
)
);
}
add_action( \'init\', \'fitter_taxonomy\');
当我试图查看该类别的归档文件时,我得到了一个404错误。有人知道为什么吗?
所以当我去mysite的时候。com/fitter它将列出所有帖子。如果我想去我的网站。com/fitter/类别名称我收到404错误