我创建了一个自定义帖子类型和一个自定义分类法。问题是,我无法将自定义帖子与它所在的类别进行分层。我有以下代码,
function AppManager_custom_post() {
$labels = array(
\'name\' => _x( \'APKS\', \'post type general name\' ),
\'singular_name\' => _x( \'APK\', \'post type singular name\' ),
\'add_new\' => _x( \'Add New APK\', \'APK\' ),
\'add_new_item\' => __( \'Add New APK\' ),
\'edit_item\' => __( \'Edit APK\' ),
\'new_item\' => __( \'New APK\' ),
\'all_items\' => __( \'All APKs\' ),
\'view_item\' => __( \'View APK\' ),
\'search_items\' => __( \'Search APKs\' ),
\'not_found\' => __( \'No APK found\' ),
\'not_found_in_trash\' => __( \'No APKs found in the Trash\' ),
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Holds Apps and meta data\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'thumbnail\', \'excerpt\' ),
\'has_archive\' => true,
\'hierarchical\' => true,
\'rewrite\' => array(\'slug\' => \'APKs\')
);
register_post_type( \'apps_post\', $args );
flush_rewrite_rules();
}
add_action( \'init\', \'AppManager_custom_post\' );
我有以下内容来创建分类法,
function AppManager_custom_taxonomy() {
$labels = array(
\'name\' => _x( \'App Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'App Category\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search App Categories\' ),
\'all_items\' => __( \'All App Categories\' ),
\'parent_item\' => __( \'Parent App Category\' ),
\'parent_item_colon\' => __( \'Parent App Category:\' ),
\'edit_item\' => __( \'Edit App Category\' ),
\'update_item\' => __( \'Update App Category\' ),
\'add_new_item\' => __( \'Add New App Category\' ),
\'new_item_name\' => __( \'New App Category\' ),
\'menu_name\' => __( \'App Categories\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
\'rewrite\' => array( \'hierarchical\' => true, \'slug\' => \'Apps\' )
);
register_taxonomy( \'appCategory\', \'apps_post\', $args );
}
add_action( \'init\', \'AppManager_custom_taxonomy\', 0 );
无论我如何尝试层次函数,它都不会映射到我添加到的类别。有可能吗?