我花了一天的大部分时间试图弄明白这一点。我的自定义分类显示在WordPress admin中,我可以将其添加到nav并使用wp\\u nav\\u菜单显示,但当我单击任何术语时,我会得到404,即使我有一个分类。主题中的php。有什么想法吗?
/** Product custom post type **/
add_action( \'init\', \'product_post_type\' );
function product_post_type() {
register_post_type( \'product\',
array(
\'labels\' => array(
\'name\' => __( \'Products\' ),
\'singular_name\' => __( \'Product\' ),
\'add_new_item\' => __( \'Add New Product\' ),
\'new_item\' => __(\'New Product\'),
\'all_items\' => __( \'All Products\' ),
\'view_item\' => __(\'View Products\' ),
\'search_items\' => __(\'Search Products\'),
\'not_found\' => __(\'No Products found\'),
\'not_found_in_trash\' => __(\'No Products found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => __(\'Products\')
),
\'menu_position\' => 5,
\'public\' => true,
\'taxonomies\' => array(\'product\')
)
);
}
/** product Taxonomy **/
add_action( \'init\', \'create_product_taxonomy\' );
function create_product_taxonomy()
{
$labels = array(
\'name\' => __( \'Product Categories\' ),
\'singular_name\' => __( \'Product Category\' ),
\'search_items\' => __( \'Search Product Categories\' ),
\'all_items\' => __( \'All Product Categories\' ),
\'parent_item\' => __( \'Parent Product Category\' ),
\'parent_item_colon\' => __( \'Parent Product Category:\' ),
\'edit_item\' => __( \'Edit Product Category\' ),
\'update_item\' => __( \'Update Product Category\' ),
\'add_new_item\' => __( \'Add Product Category\' ),
\'new_item_name\' => __( \'New Product Category\' ),
\'menu_name\' => __( \'Product Categories\' ),
);
register_taxonomy(\'product\', array(\'product\'), array(
\'public\' => true,
\'hierarchical\' => true,
\'labels\' => $labels,
\'query_var\' => true
));
}