Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在wordpress中为类别和子类别创建相对url_Wordpress - Fatal编程技术网

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

在wordpress中为类别和子类别创建相对url,wordpress,Wordpress,wordpress url中存在问题。我已经创建了自定义帖子类型和自定义分类法。当我点击分类时,下面的url会出现在url栏中 root/product-category/category 在单击子类别时,它会显示以下url root/product-category/subcategory 但我想显示以下url root/product-category/category/subcategory 这是自定义帖子类型的代码 add_action('init','rf_main_pr

wordpress url中存在问题。我已经创建了自定义帖子类型和自定义分类法。当我点击分类时,下面的url会出现在url栏中

root/product-category/category
在单击子类别时,它会显示以下url

root/product-category/subcategory
但我想显示以下url

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);
}

尝试更改woocommerce永久链接设置,但我没有使用woocommerce。应以root/prod cat/cat/sub格式显示。。。也许你的父类别没有分配给你的子类别??我知道如何在wordpress中添加类别和子类别。请:)