Wordpress Custom Post Type Registration


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.