1

我目前正在尝试使用 WOrdPress 自定义帖子类型来创建支持票证系统,目前我有以下内容并且工作正常。

add_action( 'init', 'create_support_tickets' );


function create_support_tickets() {
register_post_type( 'support_ticket',
array(
'labels' => array(
'name' => 'Tickets',
'singular_name' => 'Ticket',
'add_new' => 'Add New',
'add_new_item' => 'Add New Ticket',
'edit' => 'Edit',
'edit_item' => 'Edit Ticket',
'new_item' => 'New Ticket',
'view' => 'View',
'view_item' => 'View Ticket',
'search_items' => 'Search Tickets',
'not_found' => 'No Tickets found',
'not_found_in_trash' =>
'No Tickets found in Trash',
'parent' => 'Parent Ticket'
),
'public' => true,
'menu_position' => 15,
'supports' =>
array( 'title', 'editor', 'comments',
'thumbnail',  ),
'taxonomies' => array( '' ),
'menu_icon' =>
plugins_url( 'images/image.png', __FILE__ ),
'has_archive' => true
)
);

上面的代码有效,但我不确定如何为上面的工单添加类别,我希望能够将这些工单分配给其他具有员工角色的 WordPress 用户。

4

5 回答 5

2

这是一个关于WordPress 自定义帖子类型的很好的教程,每一个点都得到了充分的描述,对你将来有很大的帮助。

WordPress 自定义帖子类型

另一个例子在这里http://blog.teamtreehouse.com/create-your-first-wordpress-custom-post-type但我个人建议你遵循第一个。

干杯;)

于 2013-10-07T03:27:08.673 回答
1

在 function.php 中添加此代码:

add_action( 'init', 'create_services' );

function create_services() {
  $labels = array(
    'name' => _x('SERVICES', 'post type general name'),
    'singular_name' => _x('SERVICES', 'post type singular name'),
    'add_new' => _x('Add New', 'SERVICES'),
    'add_new_item' => __('Add New SERVICES'),
    'edit_item' => __('Edit SERVICES'),
    'new_item' => __('New SERVICES'),
    'view_item' => __('View SERVICES'),
    'search_items' => __('Search SERVICES'),
    'not_found' =>  __('No SERVICES found'),
    'not_found_in_trash' => __('No SERVICES found in Trash'),
    'parent_item_colon' => ''
  );

  $supports = array('title','editor','excerpt', 'trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes');

  register_post_type( 'services', 
    array(
      'labels' => $labels,
      'public' => true,
      'supports' => $supports,
      'hierarchical' => true,
      'rewrite' => array('slug' => 'services', 'with_front' => false),
    )
  );
}
于 2013-12-11T10:41:56.467 回答
0

通过'taxonomies' => array('category'),。如果您使用的是自定义帖子类型,那么您真的需要了解分类法才能在 wp 中真正使用自定义帖子类型

于 2013-10-07T02:46:06.223 回答
0

我有一个关于自定义帖子类型的教程 - 包含 HTML 和 CSS。http://fearlessflyer.com/create-a-testimonials-section-for-your-wordpress-site-the-right-way/

于 2015-01-09T19:09:12.670 回答
-1
      /**  Meet the team custom post 
You can use below wordpress script to create custom post type without any plugins */

      $labels = array(
        'name' => _x('Team', 'Team', 'Team') ,
        'singular_name' => _x('Team', 'Team', 'rjis') ,
        'menu_name' => _x('Meet the Team', 'admin menu', 'rjis') ,
        'name_admin_bar' => _x('Team', 'add new on admin bar', 'rjis') ,
        'add_new' => _x('Add New', 'Team', 'rjis') ,
        'add_new_item' => __('Add New Team', 'rjis') ,
        'new_item' => __('New Team', 'rjis') ,
        'edit_item' => __('Edit Team', 'rjis') ,
        'view_item' => __('View Team', 'rjis') ,
        'all_items' => __('All Team Members', 'rjis') ,
        'search_items' => __('Search Team', 'rjis') ,
        'parent_item_colon' => __('Parent Team:', 'rjis') ,
        'not_found' => __('No Team found.', 'rjis') ,
        'not_found_in_trash' => __('No Team found in Trash.', 'rjis')
      );
      $args = array(
        'labels' => $labels,
        'description' => __('Description.', 'Meet the team') ,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'query_var' => true,
        'rewrite' => array(
          'slug' => 'team'
        ) ,
        'capability_type' => 'post',
        'has_archive' => false,
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array(
          'title',
          'editor',
          'author',
          'thumbnail',
          'excerpt'
        ) ,
        'menu_icon' => PLUGIN_URL . "images/team.png"
      );

     register_post_type('team', $args);
于 2017-07-03T13:59:51.847 回答