Подскажите, как постам дать возможность назначать кастомную рубрику. Вот пример кода:
/*
* Регистрация таксономии производителей
*/
add_action( 'init', 'create_vendor_taxonomies' );
// функция, создающая таксономии "vendors" для постов типа "vendor"
function create_vendor_taxonomies(){
// Добавляем древовидную таксономию 'vendor' (как категории)
register_taxonomy('vendors', array('vendor', 'post'), array(
'hierarchical' => true,
'labels' => array(
'name' => _x( 'Vendors', 'taxonomy general name' ),
'singular_name' => _x( 'Vendor', 'taxonomy singular name' ),
'search_items' => __( 'Search Vendors' ),
'all_items' => __( 'All Vendors' ),
'parent_item' => __( 'Parent Vendor' ),
'parent_item_colon' => __( 'Parent Vendor:' ),
'edit_item' => __( 'Edit Vendor' ),
'update_item' => __( 'Update Vendor' ),
'add_new_item' => __( 'Add New Vendor' ),
'new_item_name' => __( 'NewVendor Name' ),
'menu_name' => __( 'Vendors' ),
),
'show_ui' => true,
'query_var' => true,
//'rewrite' => array( 'slug' => 'the_genre' ), // свой слаг в URL
));
}
/*
* Тип записей для производителей Тип записи vendor
*/
function create_vendors_posttype() {
$labels = array(
'name' => _x( 'Вендоры', 'Тип записей Вендоры', 'bahisyasal' ),
'singular_name' => _x( 'Вендор', 'Тип записей вендоры', 'bahisyasal' ),
'menu_name' => __( 'Вендоры', 'bahisyasal' ),
'all_items' => __( 'Все производители', 'bahisyasal' ),
'view_item' => __( 'Обзор производителя', 'bahisyasal' ),
'add_new_item' => __( 'Добавить нового производителя', 'bahisyasal' ),
'add_new' => __( 'Добавить нового производителя', 'bahisyasal' ),
'edit_item' => __( 'Редактировать производителя', 'bahisyasal' ),
'update_item' => __( 'Обновить произаодителя', 'bahisyasal' ),
'search_items' => __( 'Искать производителя', 'bahisyasal' ),
'not_found' => __( 'Не найдено', 'bahisyasal' ),
'not_found_in_trash' => __( 'Не найдено в корзине', 'bahisyasal' ),
);
$args = array(
'label' => __( 'vendor', 'bahisyasal' ),
'description' => __( 'Каталог производителей', 'bahisyasal' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
'taxonomies' => array( 'category', 'vendors' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'menu_icon' => 'dashicons-groups',
'capability_type' => 'page',
);
register_post_type( 'vendors', $args );
}
add_action( 'init', 'create_vendors_posttype', 0 );
Подскажите как для обычных постов сделать связь с постами типа vendor из таксономии vendors ?
Что то по типу Меток. Только что б для Производителей ?