只是澄清一下,Parst通过一个自定义分类注册码的工作示例指出了什么:
$labels = array(
\'name\' => _x( \'Issue numbers\', \'taxonomy general name\', \'sascha_setup_post_type\' ),
\'singular_name\' => _x( \'Issue number\', \'taxonomy singular name\', \'sascha_setup_post_type\' ),
\'search_items\' => __( \'Search issues\', \'sascha_setup_post_type\' ),
\'all_items\' => __( \'All issue numbers\', \'sascha_setup_post_type\' ),
\'parent_item\' => __( \'Year of publication\', \'sascha_setup_post_type\' ),
\'parent_item_colon\' => __( \'Year of publication:\', \'sascha_setup_post_type\' ),
\'edit_item\' => __( \'Edit issue number\', \'sascha_setup_post_type\' ),
\'update_item\' => __( \'Update issue number\', \'sascha_setup_post_type\' ),
\'add_new_item\' => __( \'Add new issue number\', \'sascha_setup_post_type\' ),
\'new_item_name\' => __( \'New issue number\', \'sascha_setup_post_type\' ),
\'menu_name\' => __( \'Issue numbers\', \'sascha_setup_post_type\' ),
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'issues\', \'hierarchical\' => true ),
);
register_taxonomy( \'issue_number\', array( \'post\', \'issue\' ), $args );
结果给出了一个类似www.yourdomain的url。com/issues/2016/04/-正如您所愿。和在实现了这一点之后,不要忘记刷新permalink规则,不要为自定义分类URL获取404。最简单的方法-转到Admin/Permalinks,只需点击“save”(保存)按钮,无需更改任何内容。