我正在尝试创建我的网站页脚部分,其中包含来自父级的术语链接li,用于我创建的自定义分类法。
function add_custom_taxonomies() {
// Add new "producttype" taxonomy to products
register_taxonomy(\'producttype\', \'product\', array(
// Hierarchical taxonomy (like categories)
\'hierarchical\' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
\'labels\' => array(
\'name\' => _x( \'Producttypes\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Producttype\', \'taxonomy singular name\' ),
\'search_items\' => __( \'Search Producttypes\' ),
\'all_items\' => __( \'All Producttypes\' ),
\'parent_item\' => __( \'Parent Producttype\' ),
\'parent_item_colon\' => __( \'Parent Producttype:\' ),
\'edit_item\' => __( \'Edit Producttype\' ),
\'update_item\' => __( \'Update Producttype\' ),
\'add_new_item\' => __( \'Add New Producttype\' ),
\'new_item_name\' => __( \'New Producttype Name\' ),
\'menu_name\' => __( \'Product Type\' ),
),
// Control the slugs used for this taxonomy
\'rewrite\' => array(
\'slug\' => \'Producttype\', // This controls the base slug that will display before each term
\'with_front\' => false, // Don\'t display the category base before "/locations/"
\'hierarchical\' => true // This will allow URL\'s like "/locations/boston/cambridge/"
),
));
}
add_action( \'init\', \'add_custom_taxonomies\', 0 );
我为分类法“producttype”创建了一个称为“Type”的父项,我只想获取父项“Type”下的那些子项,并将它们显示为链接。我在wordpress仪表板中手动创建了父术语。