当我访问我的自定义分类页面时,我得到了一个404页面。自定义分类法称为“制造商”。我还有一个名为“产品”的cpt。
EDIT 1:这与cpt重写有关。如果禁用重写,分类法工作正常。
注意事项:
permalinks flush无助于模板分类制造商。php exists WP version is 4.4.2 WP category具有基“kategorie”
post url设置为“post name”cpt应具有“pretty url”(无任何前缀) function product_post_type() {
$labels = array(
\'name\' => _x( \'Products\', \'Post Type General Name\' ),
\'singular_name\' => _x( \'Product\', \'Post Type Singular Name\' ),
\'menu_name\' => __( \'Products\' ),
\'name_admin_bar\' => __( \'Product\' ),
\'archives\' => __( \'Products Archives\' ),
\'parent_item_colon\' => __( \'Parent Product:\' ),
\'all_items\' => __( \'All Products\' ),
\'add_new_item\' => __( \'Add New Product\' ),
\'add_new\' => __( \'Add New\' ),
\'new_item\' => __( \'New Product\' ),
\'edit_item\' => __( \'Edit Product\' ),
\'update_item\' => __( \'Update Product\' ),
\'view_item\' => __( \'View Product\' ),
\'search_items\' => __( \'Search Product\' ),
\'not_found\' => __( \'Product Not found\' ),
\'not_found_in_trash\' => __( \'Product Not found in Trash\' ),
\'featured_image\' => __( \'Featured Image\' ),
\'set_featured_image\' => __( \'Set featured image\' ),
\'remove_featured_image\' => __( \'Remove featured image\' ),
\'use_featured_image\' => __( \'Use as featured image\' ),
\'insert_into_item\' => __( \'Insert into product\' ),
\'uploaded_to_this_item\' => __( \'Uploaded to this product\' ),
\'items_list\' => __( \'Products list\' ),
\'items_list_navigation\' => __( \'Products list navigation\' ),
\'filter_items_list\' => __( \'Filter products list\' ),
);
$args = array(
\'label\' => __( \'Products\' ),
\'description\' => __( \'Product Description\' ),
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\' ),
\'taxonomies\' => array( \'category\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'menu_position\' => 5,
\'show_in_admin_bar\' => true,
\'show_in_nav_menus\' => true,
\'can_export\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'query_var\' => true,
\'capability_type\' => \'post\',
\'rewrite\' => array(\'slug\' => \'/\'),
\'has_archive\' => true
);
register_post_type( \'product\', $args );
}
add_action( \'init\', \'product_post_type\', 0 );
这是自定义分类“制造商”:
function manufacturer_taxonomy(){
$labels = array(
\'name\' => _x( \'Herstellers\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Hersteller\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Hersteller\' ),
\'all_items\' => __( \'All Hersteller\' ),
\'parent_item\' => __( \'Parent Hersteller\' ),
\'parent_item_colon\' => __( \'Parent Hersteller:\' ),
\'edit_item\' => __( \'Edit Hersteller\' ),
\'update_item\' => __( \'Update Hersteller\' ),
\'add_new_item\' => __( \'Add New Hersteller\' ),
\'new_item_name\' => __( \'New Hersteller Name\' ),
\'menu_name\' => __( \'Hersteller\' ),
);
register_taxonomy( \'manufacturer\', \'product\', array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'slug\' => \'hersteller\',
\'with_front\' => false
),
));
}
add_action(\'init\',\'manufacturer_taxonomy\',0);
任何想法都很好。