2017-07-20 39 views
0

我为WooCommerce产品创建了自定义分类标准。产品不工作的自定义分类标准

function add_hunts_type(){ 
// Car Hunts 
    $cHunt_labels = array(
     'name'    => __('Hunts', 'pixar'), 
     'singular_name'  => __('Hunt', 'pixar'), 
     'search_items'  => __('Search Hunts', 'pixar'), 
     'all_items'   => __('All Hunts', 'pixar'), 
     'parent_item'  => __('Parent Hunt', 'pixar'), 
     'parent_item_colon' => __('Parent Hunt:', 'pixar'), 
     'edit_item'   => __('Edit Hunt', 'pixar'), 
     'update_item'  => __('Update Hunt', 'pixar'), 
     'add_new_item'  => __('Add New Hunt', 'pixar'), 
     'new_item_name'  => __('New Hunt', 'pixar'), 
     'menu_name'   => __('Hunts', 'pixar'), 
    ); 
    $cHunt_args = array(
    'labels' => $cHunt_labels, 
    'hierarchical'    => true, 
    'public'      => true, 
    'show_ui'     => true, 
    'show_admin_column'   => true, 
    'show_in_nav_menus'   => true, 
    'show_tagcloud'    => true, 
    'query_var' => true, 
    'rewrite' => array('slug' => 'carhunt') 
    ); 
    register_taxonomy('car_Hunt', 'product', $cHunt_args); 
} 
add_action('init', 'add_hunts_type', 0); 

    /* Flush rewrite rules for custom post types. */ 
add_action('after_switch_theme', 'flush_rewrite_rules'); 

这是工作时,我登录到管理员。当我想从前端尝试时,它不起作用。

  • 我有变化的永久链接
  • 我已删除.htaccess和再生它
  • 我还有其他的内在的东西这是正常

请让我知道如果我错过了一些东西。

回答

0

注册自定义分类中WooCommerce

在function.php下面添加功能

<?php 
// Register Custom Taxonomy 
function custom_taxonomy_Hunt() { 

    $labels = array(
     'name'      => 'Hunts', 
     'singular_name'    => 'Hunt', 
     'menu_name'     => 'Hunt', 
     'all_items'     => 'All Hunts', 
     'parent_item'    => 'Parent Hunt', 
     'parent_item_colon'   => 'Parent Hunt:', 
     'new_item_name'    => 'New Hunt Name', 
     'add_new_item'    => 'Add New Hunt', 
     'edit_item'     => 'Edit Hunt', 
     'update_item'    => 'Update Hunt', 
     'separate_items_with_commas' => 'Separate Hunt with commas', 
     'search_items'    => 'Search Hunts', 
     'add_or_remove_items'  => 'Add or remove Hunts', 
     'choose_from_most_used'  => 'Choose from the most used Hunts', 
    ); 
    $args = array(
     'labels'      => $labels, 
     'hierarchical'    => true, 
     'public'      => true, 
     'show_ui'     => true, 
     'show_admin_column'   => true, 
     'show_in_nav_menus'   => true, 
     'show_tagcloud'    => true, 
     'query_var'     => true, 
     'rewrite'     => array('slug' => 'carhunt') 
    ); 
    register_taxonomy('carhunt', 'product', $args); 
    register_taxonomy_for_object_type('carhunt', 'product'); 

} 
add_action('init', 'custom_taxonomy_Hunt'); 
?> 
+0

感谢您help.This工作,但我忘了把破折号slugname( - )。好去继续下去这里有很多要学习的东西。 –

+0

欢迎您:) –

相关问题