在wordpress中为类别和子类别创建相对URL

时间:2016-02-15 10:29:56

标签: wordpress

wordpress网址存在问题。我创建了自定义的post-type和custom-taxonomy。当我点击类别时,后面的网址会显示在网址栏中。

root/product-category/category

当点击子类别时,它会显示以下网址。

root/product-category/subcategory

但我想显示以下网址,

root/product-category/category/subcategory

以下是自定义帖子类型的代码,

    add_action('init','rf_main_products');
function rf_main_products(){
    $args=array
        (
            'labels' => array(
                'name' => __('Products'),
                'singular_name' => __('Product'),
                'add_new' => __('Add New Product'),
                'add_new_item' => __('Add New Product'),
                'edit_item' => __('Edit Product'),
                'new_item' => __('New Product'),
                'view_item' => __('View Product'),
                'search_items' => __('Search Product'),
                'not_found' =>  __('No Product found'),
                'not_found_in_trash' => __('No Product found in Trash'),
            ),
            'public' => true,
            'has_archive' => true,
            'rewrite' => array('slug' => 'mainproducts'),
            'supports'=>array('title','editor','thumbnail'),
            'hierarchical'=>true,
            'taxonomies'=>array('main_product_category','tags')
        );
    register_post_type('rf_main_products',$args);
}

0 个答案:

没有答案