Wordpress register custom post type


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



Copy this code and paste it in your HTML
  1. // creating (registering) the custom type
  2. $labels = array(
  3. 'name' => _x('Custom Types', 'post type general name', 'big_bang'), //This is the title of the group
  4. 'singular_name' => _x('Custom Post', 'post type singular name', 'big_bang'), //This is the individual type
  5. 'add_new' => _x('Add New', 'custom post type item', 'big_bang'), //The add new menu item
  6. 'add_new_item' => __('Add New Custom Type', 'big_bang'), // Add new Display Title
  7. 'all_items' => __('All Custom Types', 'big_bang'), // The All Items in the Menu
  8. 'edit' => __('Edit', 'big_bang'), //Edit Dialog
  9. 'edit_item' => __('Edit Custom Type', 'big_bang'), //Edit Display Title
  10. 'new_item' => __('New Custom Type', 'big_bang'), //New Display Title
  11. 'view_item' => __('View Custom Type', 'big_bang'), //View Display Title
  12. 'search_items' => __('Search Custom Post Type', 'big_bang'), //Search Custom Type Title
  13. 'not_found' => __('Nothing found in the Database.', 'big_bang'), //This displays if there are no entries yet
  14. 'not_found_in_trash'=> __('Nothing found in Trash', 'big_bang'), //This displays if there is nothing in the trash
  15. 'parent_item_colon' => ''
  16. );
  17. $args = array(
  18. 'labels' => $labels,
  19. 'description' => __('This is an example custom post type.', 'big_bang'), //Custom Type Description
  20. 'public' => true,
  21. 'publicly_queryable' => true,
  22. 'exclude_from_search' => false,
  23. 'show_ui' => true,
  24. 'query_var' => true,
  25. 'menu_position' => 8, //This is what order you want it to appear in on the left hand side menu
  26. 'menu_icon' => get_stylesheet_directory_uri() . '/images/custom-post-icon.png', //the icon for the custom post type menu
  27. 'rewrite' => true,
  28. 'capability_type' => 'post',
  29. 'hierachical' => false,
  30. // the next one is important, it tells what's enabled in the post editor
  31. 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky')
  32. );
  33.  
  34. register_post_type( 'custom_type', $args); // (http://codex.wordpress.org/Function_Reference/register_post_type)

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.