首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Wordpress上创建Custum纺织品和Post类型

在Wordpress上创建Custum纺织品和Post类型
EN

Stack Overflow用户
提问于 2015-09-18 10:56:30
回答 1查看 90关注 0票数 1

我正试图在wordpress上创建custum纺织学。如何创建它?

这是我的密码:

代码语言:javascript
复制
add_action( 'init', 'create_post' );
    function create_post() {

        $labels = array(
            'name' => _x('Post', 'Post General Name', 'gdl_back_office'),
            'singular_name' => _x('Speakpool Item', 'Post Singular Name', 'gdl_back_office'),
            'add_new' => _x('Add New', 'Add New Post Name', 'gdl_back_office'),
            'add_new_item' => __('Author Name', 'gdl_back_office'),
            'edit_item' => __('Author Name', 'gdl_back_office'),
            'new_item' => __('New Post', 'gdl_back_office'),
            'view_item' => '',
            'search_items' => __('Search Post', 'gdl_back_office'),
            'not_found' =>  __('Nothing found', 'gdl_back_office'),
            'not_found_in_trash' => __('Nothing found in Trash', 'gdl_back_office'),
            'parent_item_colon' => ''
        );

        $args = array(
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            //'menu_icon' => GOODLAYERS_PATH . '/include/images/portfolio-icon.png',
            'rewrite' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_position' => 5,
            "show_in_nav_menus" => false,
            'exclude_from_search' => true,
            'supports' => array('title','editor','author','thumbnail','excerpt','comments')
        ); 

        register_post_type( 'Post' , $args);

        register_taxonomy( 'Post_category', 'Post', array( 
            'hierarchical' => true, 'label' => 'Post Category', 'query_var' => true, "show_in_nav_menus" => true, 'rewrite' => true ) );

    }

它的类型,但不适用于纺织品。帮帮我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-18 11:10:51

删除register_taxonomy()并尝试此代码,根据需要更改名称:

代码语言:javascript
复制
function create_video_blog_taxonomies() {
    $labels = array(
        'name'              => _x( 'Video Categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Category', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Categories' ),
        'all_items'         => __( 'All Categories' ),
        'parent_item'       => __( 'Parent Category' ),
        'parent_item_colon' => __( 'Parent Category:' ),
        'edit_item'         => __( 'Edit Category' ),
        'update_item'       => __( 'Update Category' ),
        'add_new_item'      => __( 'Add New Category' ),
        'new_item_name'     => __( 'New Category Name' ),
        'menu_name'         => __( 'Video Categories' ),
    );

    $args = array(
        'hierarchical'      => true, // Set this to 'false' for non-hierarchical taxonomy (like tags)
        'labels'            => $labels,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'categories' ),
    );

    register_taxonomy( 'video_blog_categories', array( 'video_blog' ), $args );
}
add_action( 'init', 'create_video_blog_taxonomies', 0 );

独立的Custum桩型函数和Texomony函数

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32650270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档