Answer the question
In order to leave comments, you need to log in
How to make CNC with categories for taxonomy?
Hello, I saw a lot of similar questions asked, but there are no sensible answers with a solution.
It is necessary to make CNC so that they have categories, subcategories and the name of the product itself, like breadcrumbs, and how to set up a template for them to display posts and categories?
function create_post_type() {
register_post_type( 'service',
array(
'labels' => array(
'name' => __( 'Услуги' ),
'singular_name' => __( 'Услуга' ),
'add_new' => __( 'Новая услуга' ),
'edit_item' => __( 'Редактировать услугу' )
),
'public' => true,
'has_archive' => true,
'supports' => array('title','editor','thumbnail'),
'rewrite' => array( 'slug' => 'service', 'hierarchical' => true ),
)
);
}
add_action( 'init', 'create_custom_taxonomy');
function create_custom_taxonomy() {
// Add new taxonomy, make it hierarchical (like categories)
$args = array(
'labels' => array(
'name' => __( 'Рубрики услуг' ),
),
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'services', 'hierarchical' => true ),
);
register_taxonomy( 'services', array( 'service' ), $args );
}
'rewrite' => array( 'slug' => 'service', 'hierarchical' => true ),
Answer the question
In order to leave comments, you need to log in
In the admin panel, on the /wp-admin/options-permalink.php
page,
select arbitrarily and write there:
All categories and subcategories to which the page belongs will be displayed in the URL.
Full list of available tags here:
https://codex.wordpress.org/Using_Permalinks
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question