Wordpress自定义Post类型注册

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress自定义Post类型注册相关的知识,希望对你有一定的参考价值。

Code for the wordpress functions file to add a custom post type.

Full doc at:
http://codex.wordpress.org/Function_Reference/register_post_type

http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress
  1. add_action('init', 'my_custom_init');
  2. function my_custom_init()
  3. {
  4. $labels = array(
  5. 'name' => _x('Books', 'post type general name'),
  6. 'singular_name' => _x('Book', 'post type singular name'),
  7. 'add_new' => _x('Add New', 'book'),
  8. 'add_new_item' => __('Add New Book'),
  9. 'edit_item' => __('Edit Book'),
  10. 'new_item' => __('New Book'),
  11. 'view_item' => __('View Book'),
  12. 'search_items' => __('Search Books'),
  13. 'not_found' => __('No books found'),
  14. 'not_found_in_trash' => __('No books found in Trash'),
  15. 'parent_item_colon' => ''
  16. );
  17. $args = array(
  18. 'labels' => $labels,
  19. 'public' => true,
  20. 'rewrite' => true,
  21. 'capability_type' => 'post',
  22. 'hierarchical' => false,
  23. 'supports' => array('title','editor','author','thumbnail','excerpt','comments')
  24. );
  25. register_post_type('book',$args);
  26. }

以上是关于Wordpress自定义Post类型注册的主要内容,如果未能解决你的问题,请参考以下文章

从 Wordpress 取消注册自定义帖子类型

Wordpress注册自定义Post类型和自定义分类法

Wordpress注册自定义post类型

没有自定义帖子类型 slug 的 WordPress slug

Wordpress 自定义帖子类型类别

用于自定义帖子类型的 Wordpress 多个 slug