WP Не отображает шаблон для кастомного типа поста

Подскажите, создал произвольную таксономию vendors для неё создал кастомный тип записи постов games . Не могу понять почему не отображается шаблон записи.


//
///*
// *  Регистрация таксономии производителей
// */

add_action( 'init', 'create_vendor_taxonomies' );

// функция, создающая таксономии "vendors" для постов типа "vendor"
function create_vendor_taxonomies(){

    // Добавляем недревовидную таксономию 'vendors' (как метки)
    register_taxonomy('vendors', array('vendor', 'post', 'games'), array(
        'hierarchical'  => true,
        'labels'        => array(
            'name'              => _x( 'Производители', 'taxonomy general name' ),
            'singular_name'     => _x( 'Vendor', 'taxonomy singular name' ),
            'search_items'      => __( 'Поиск производителей' ),
            'all_items'         => __( 'Все производители' ),
            'parent_item'       => __( 'Parent Vendor' ),
            'parent_item_colon' => __( 'Parent Vendor:' ),
            'edit_item'         => __( 'Править производителя' ),
            'update_item'       => __( 'Обновить производителя' ),
            'add_new_item'      => __( 'Добавить нового производителя' ),
            'new_item_name'     => __( 'Имя нового производителя' ),
            'menu_name'         => __( 'Vendors' ),
        ),
        'show_ui'       => true,
        'show_in_rest'  => true,
        'query_var'     => true,
        'has_archive' => true,
    ));
}

/*
 *  Тип записей для производителей Тип записи Game
 */

function create_games_posttype() {
    $labels = array(
        'name' => _x( 'Games', 'Тип записей Games', 'bahisyasal' ),
        'singular_name' => _x( 'Game', 'Тип записей game', 'bahisyasal' ),
        'menu_name' => __( 'Games', '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' => __( 'games', 'bahisyasal' ),
        'description' => __( 'Каталог игр', 'bahisyasal' ),
        'labels' => $labels,
        'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions', 'custom-fields', 'post-formats' ),
        'taxonomies' => array('vendors'),
        'hierarchical' => true,
        '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,

        'rewrite'   => array(
            'slug' => '/%vendors%',   // тип поста и сама таксономия
            'with_front' => false
        ),
        'exclude_from_search' => false,
        'publicly_queryable' => true,
        'menu_icon' => 'dashicons-buddicons-activity',
        'capability_type' => 'post',
    );

    register_post_type( 'games', $args );
}
add_action( 'init', 'create_games_posttype', 0 );


/// Корректировка слага для games
add_filter('post_type_link', 'vendors_permalink', 1, 2 );
function vendors_permalink( $permalink, $post ) {
    if ( strpos( $permalink, '%vendors%' ) === false ) {
        return $permalink;
    }

    $terms = get_the_terms( $post, 'vendors' );

    if ( ! is_wp_error( $terms ) && ! empty( $terms ) && is_object( $terms[0] ) ) {
        $taxonomy_slug = $terms[0]->slug;
    } else{
        $taxonomy_slug = 'no-vendors';
    }

    return str_replace( '%vendors%', $taxonomy_slug, $permalink );
}

введите сюда описание изображения

Пробовал и single-games.php и vendors-games.php, но почему-то 404 страницу отдает. Если поменять постоянные ссылки на тип %category%/%postname% то single-games.php начинает работать, но тогда перестают работать single.php и taxonomy-vendors.php. Может кто-то посоветовать как решить проблему ?


Ответы (0 шт):