jacall.net
前端开发工作者
© JaCall.Net
All Rights Reserved.
皖ICP备13004974号-1

添加新文章类型

<?php
// 评论文章
add_action( 'init', 'create_comm' );
function create_comm() {
    $imagepath = get_stylesheet_directory_uri() . '/images/icon/';
    $labels = array(
        'name' => _x('评论文章', 'post type general name'),
        'singular_name' => _x('评论文章', 'post type singular name'),
        'add_new' => _x('添加文章', 'Comm'),
        'add_new_item' => __('添加文章'),
        'edit_item' => __('编辑文章'),
        'new_item' => __('New Comm'),
        'view_item' => __('View Comm'),
        'search_items' => __('Search Comm'),
        'not_found' =>  __('No Comm found'),
        'not_found_in_trash' => __('No Comm found in Trash'),
        'parent_item_colon' => ''
    );
    $supports = array('title', 'editor');
    register_post_type( 'comm',
        array(
          'labels' => $labels,
          'public' => true,
          'menu_position'=>7,
          'exclude_from_search' => true,        //屏蔽前台搜索
          'menu_icon' => $imagepath.'comm.png',
          'supports' => $supports
        )
    );
}

function create_comms_taxonomy()
{
  $labels = array(
          'name' => _x( '评论分类', 'taxonomy general name' ),
          'singular_name' => _x( 'gallery', 'taxonomy singular name' ),
          'search_items' =>  __( '搜索分类' ),
          'all_items' => __( '全部分类' ),
          'parent_item' => __( '父级分类目录' ),
          'parent_item_colon' => __( '父级分类目录:' ),
          'edit_item' => __( '编辑评论分类' ),
          'update_item' => __( '更新' ),
          'add_new_item' => __( '添加新评论分类' ),
          'new_item_name' => __( 'New Genre Name' ),
  );
  register_taxonomy('comms',array('comm'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column'     => true,                //后台文章列表显示所属分类
    'query_var' => true,
    'rewrite' => array( 'slug' => 'comm' ),
  ));
}
add_action( 'init', 'create_comms_taxonomy', 0 );

?>

 

2013-09-17
4,289 views
暂无评论

发表回复