在重写分类中包括产品类别库和%product_cat%

时间:2016-12-02 10:16:55

标签: wordpress url-rewriting taxonomy

我想在新分类中添加产品类别库和%product_cat%我添加到woocomerce,有什么想法吗?

    $flavour_labels = array(
    'name'                       => 'Flavours',
    'singular_name'              => 'Flavour',
    'menu_name'                  => 'Flavour',
    'all_items'                  => 'All Flavours',
    'parent_item'                => 'Parent Flavour',
    'parent_item_colon'          => 'Parent Flavour:',
    'new_item_name'              => 'New Flavour Name',
    'add_new_item'               => 'Add New Flavour',
    'edit_item'                  => 'Edit Flavour',
    'update_item'                => 'Update Flavour',
    'separate_items_with_commas' => 'Separate Flavour with commas',
    'search_items'               => 'Search Flavours',
    'add_or_remove_items'        => 'Add or remove Flavours',
    'choose_from_most_used'      => 'Choose from the most used Flavours',
);

$flavour_args = array(
    'labels'             => $flavour_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' => 'flavour'),
);

register_taxonomy( 'product_flavour', 'product', $flavour_args );
register_taxonomy_for_object_type( 'product_flavour', 'product' );

这是我的网址 http://site.local/flavour/name/

这就是我想要的 http://site.local/gear/product_cat/flavour/name/

我不想在重写中编写任何代码

1 个答案:

答案 0 :(得分:0)

  1. 确保您的.htaccess文件可写。
  2. 在"类别基础"写你的基本字符串" product_cat"没有百分号(%)
  3. enter image description here