Answer the question
In order to leave comments, you need to log in
How to make term and directory in one url?
Hello, I have a problem with vp. There is a site with products (not woocomerce), they have categories, and they should be (and available) at the url mysite.ru/producia . It displays a list of product categories. Going to the category of products, which is available at mysite.ru/producia/name_cat , all products from this category are displayed. When going to a product, it must have the URL mysite.ru/producia/name_of_product . So the problem is the following, now post_type for products is written like this:
register_post_type('products', array(
'labels' => array(
'name' => __('Продукция', 'carnon'),
),
'public' => true,
'capability_type' => 'page',
'hierarchical' => true,
'menu_icon' => 'dashicons-book',
'menu_position' => 5,
'rewrite' => array( 'slug' => 'producia', 'with_front' => false ),
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
'show_in_rest' => true,
));
register_taxonomy( 'category', [ 'products' ], [
'label' => 'Категории',
'labels' => [
'name' => 'Категории',
],
'description' => '',
'public' => true,
'hierarchical' => true,
'capabilities' => array(),
'meta_box_cb' => null,
'show_admin_column' => false,
'show_in_rest' => true,
'rest_base' => null,
'rewrite' => array( 'slug' => 'producia', 'with_front' => false ),
] );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question