functions.php
<?php
/**
* Created by PhpStorm.
* User: isaevdimka
* Date: 30/11/2018
* Time: 12:59
*/
add_theme_support( 'post-thumbnails' );
add_action('init', 'my_custom_init');
function my_custom_init(){
register_post_type('book', array(
'labels' => array(
'name' => 'Книги', // Основное название типа записи
'singular_name' => 'Книга', // отдельное название записи типа Book
'add_new' => 'Добавить новую',
'add_new_item' => 'Добавить новую книгу',
'edit_item' => 'Редактировать книгу',
'new_item' => 'Новая книга',
'view_item' => 'Посмотреть книгу',
'search_items' => 'Найти книгу',
'not_found' => 'Книг не найдено',
'not_found_in_trash' => 'В корзине книг не найдено',
'parent_item_colon' => '',
'menu_name' => 'Книги'
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','thumbnail'),
) );
}
add_action( 'init', 'create_books_author_taxonomies', 0 );
function create_books_author_taxonomies(){
$labels = array(
'name' => _x( 'Авторы', 'taxonomy general name' ),
'menu_name' => __( 'Авторы' ),
);
register_taxonomy('books_author', array('book'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'books_author' ),
));
}
add_action( 'init', 'create_books_genre_taxonomies', 0 );
function create_books_genre_taxonomies(){
$labels = array(
'name' => _x( 'Жанр', 'taxonomy general name' ),
'menu_name' => __( 'Жанры' ),
);
register_taxonomy('books_genre', array('book'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'books_genre' ),
));
}
add_action( 'init', 'create_books_year_taxonomies', 0 );
function create_books_year_taxonomies(){
$labels = array(
'name' => _x( 'Год выпуска', 'taxonomy general name' ),
'menu_name' => __( 'Год выпуска' ),
);
register_taxonomy('books_year', array('book'), array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'books_year' ),
));
}
Не выводиться ничего в файле single-book.php и archive-book.php
всегда отображается страница index.php