添加了自定义分类,仍显示类别

时间:2017-09-01 23:29:12

标签: wordpress

我为我的WordPress网站制作了一个新的插件,它有能力创建一个名为products的新帖子类型,在这个插件上我添加了一个名为产品类型的自定义分类。一切都很好,但我的Wordpress管理面板自定义帖子类型'产品'仍然显示类别选项,我不想要。这是我的插件代码,

<?php   function FLChildTheme_custom_post_type (){

 $labels = array(
'name' => 'Products',
'singular_name' => 'products',
'add_new' => 'Add Products',
'all_items' => 'All items',
'add_new_item' => 'Add item',
'edit_item' => 'Edit Item',
'new_item' => 'New Item',
'view_item' => 'View Products',
'search_item' => 'Search Product',
'not_found' => 'No Products Found',
'not_found_in_trash' => 'No product in trash',
'parent_item_colon' => 'Parent Item',

);

$args = array(
'labels' => $labels,
'public' => true,
'has_archive' => true,
'publicly_queryable' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array(
    'title',
    'editor',
    'excerpt',
    'thumbnail',
    'revisions',
   ),
   'taxonomies' => array('category','post_tag'),
   'menu_position' => 5,
   'exclude_from_search' => false,
  );
         register_post_type('products', $args);
      }

     add_action ('init', 'FLChildTheme_custom_post_type');

 /* Custom post type End*/


/* Add custom taxonomies */
    function FLChildTheme_add_custom_taxonomies() {
  // Add new "Locations" taxonomy to Posts
        register_taxonomy('Producttypes', 'products', array(
// Hierarchical taxonomy (like categories)
        'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
    'labels' => array(
      'name' => _x( 'Product Types', 'taxonomy general name' ),
      'singular_name' => _x( 'Product Type', 'taxonomy singular name' ),
      'search_items' =>  __( 'Search Product Types' ),
      'all_items' => __( 'All Product Types' ),
      'parent_item' => __( 'Parent Product Types' ),
      'parent_item_colon' => __( 'Parent Product Types:' ),
      'edit_item' => __( 'Edit Product Types' ),
      'update_item' => __( 'Update Product Types' ),
  'add_new_item' => __( 'Add New Product Types' ),
  'new_item_name' => __( 'New Product Type Name' ),
  'menu_name' => __( 'Product Types' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
  'slug' => 'Producttypes', // 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', 'FLChildTheme_add_custom_taxonomies', 0 );


     ?>

0 个答案:

没有答案