为自定义帖子类型添加类别分类?

时间:2016-04-12 18:14:19

标签: wordpress wordpress-theming custom-post-type taxonomy

我制作了一个自定义的帖子类型'游戏',在初始化时已经添加了'类别'分类。我可以为给定条目添加类别/标签,但自定义帖子不会显示在类别/标签列表中。我还没有添加任何自定义模板文件。

function register_games()
{
    register_post_type('games', array
    (
        'label'               => __('games', 'twentytwelve'),
        'description'         => __('Best iOS / Android games', 'twentytwelve'),

        // UI.
        'menu_position'       => 5,
        'menu_icon'           => 'dashicons-tablet',
        'labels'              => array
        (
            'name'                => _x('Games', 'Post Type General Name', 'twentytwelve'),
            'singular_name'       => _x('Game', 'Post Type Singular Name', 'twentytwelve'),
            'menu_name'           => __('Games', 'twentytwelve'),
            'parent_item_colon'   => __('Parent Game', 'twentytwelve'),
            'all_items'           => __('All Games', 'twentytwelve'),
            'view_item'           => __('View Game', 'twentytwelve'),
            'add_new_item'        => __('Add New Game', 'twentytwelve'),
            'add_new'             => __('Add New', 'twentytwelve'),
            'edit_item'           => __('Edit Game', 'twentytwelve'),
            'update_item'         => __('Update Game', 'twentytwelve'),
            'search_items'        => __('Search Game', 'twentytwelve'),
            'not_found'           => __('Not Found', 'twentytwelve'),
            'not_found_in_trash'  => __('Not found in Trash', 'twentytwelve'),
        ),

        // Features.
        'supports'            => array
        (
            'title',
            'editor',
            'author',
            'thumbnail',
            'excerpt',
            'trackbacks',
            'custom-fields',
            'comments',
            'revisions',
        ),

        // Attributes.
        'public'              => true,
        'taxonomies'          => array('category', 'post_tag'),
        'has_archive'         => true,

        // Admin.
        'register_meta_box_cb' => 'add_games_metaboxes'

    ));
}

摘录显示在<DOMAIN>/index.php/games/中,但不在<DOMAIN>/index.php/category/games/中(我创建并添加了此类别)。

0 个答案:

没有答案