Вот таксономия услуг
function create_services_taxonomy() {
// Services Categories
register_taxonomy('service_category', 'services', array(
'labels' => array(
'name' => 'Service Categories',
'singular_name' => 'Service Category',
'search_items' => 'Search Service Categories',
'all_items' => 'All Service Categories',
'edit_item' => 'Edit Service Category',
'update_item' => 'Update Service Category',
'add_new_item' => 'Add New Service Category',
'new_item_name' => 'New Service Category Name',
'menu_name' => 'Service Categories',
),
'hierarchical' => true, // Acts like categories
'show_admin_column' => true,
'show_in_rest' => true, // For Gutenberg support
'rewrite' => array('slug' => 'service-category'),
));
// Services Tags
register_taxonomy('service_tag', 'services', array(
'labels' => array(
'name' => 'Service Tags',
'singular_name' => 'Service Tag',
'search_items' => 'Search Service Tags',
'all_items' => 'All Service Tags',
'edit_item' => 'Edit Service Tag',
'update_item' => 'Update Service Tag',
'add_new_item' => 'Add New Service Tag',
'new_item_name' => 'New Service Tag Name',
'menu_name' => 'Service Tags',
),
'hierarchical' => false, // Acts like tags
'show_admin_column' => true,
'show_in_rest' => true, // For Gutenberg support
'rewrite' => array('slug' => 'service-tag'),
));
}
add_action('init', 'create_services_taxonomy');
function create_services_post_type() {
register_post_type('services', array(
'labels' => array(
'name' => 'Services',
'singular_name' => 'Service',
'add_new' => 'Add New',
'add_new_item' => 'Add New Service',
'edit_item' => 'Edit Service',
'new_item' => 'New Service',
'view_item' => 'View Service',
'search_items' => 'Search Services',
'not_found' => 'No services found',
'not_found_in_trash' => 'No services found in Trash',
),
'public' => true,
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields'), // You can add more supported features if needed
'show_in_rest' => true, // Important for Gutenberg support
'rewrite' => array('slug' => 'services'),
));
}
add_action('init', 'create_services_post_type');
Подробнее здесь: https://stackoverflow.com/questions/791 ... rvice-page
Мобильная версия