create_initial_post_types

Creates the initial post types when 'init' action is fired.

Description

create_initial_post_types(); 

See .


Usage

  1. if ( !function_exists( 'create_initial_post_types' ) ) { 
  2. require_once ABSPATH . WPINC . '/post.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = create_initial_post_types(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/post.php  
  1. function create_initial_post_types() { 
  2. register_post_type( 'post', array( 
  3. 'labels' => array( 
  4. 'name_admin_bar' => _x( 'Post', 'add new from admin bar' ),  
  5. ),  
  6. 'public' => true,  
  7. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  8. '_edit_link' => 'post.php?post=%d', /** internal use only. don't use this when registering your own post type. */ 
  9. 'capability_type' => 'post',  
  10. 'map_meta_cap' => true,  
  11. 'menu_position' => 5,  
  12. 'hierarchical' => false,  
  13. 'rewrite' => false,  
  14. 'query_var' => false,  
  15. 'delete_with_user' => true,  
  16. 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),  
  17. 'show_in_rest' => true,  
  18. 'rest_base' => 'posts',  
  19. 'rest_controller_class' => 'WP_REST_Posts_Controller',  
  20. ) ); 
  21.  
  22. register_post_type( 'page', array( 
  23. 'labels' => array( 
  24. 'name_admin_bar' => _x( 'Page', 'add new from admin bar' ),  
  25. ),  
  26. 'public' => true,  
  27. 'publicly_queryable' => false,  
  28. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  29. '_edit_link' => 'post.php?post=%d', /** internal use only. don't use this when registering your own post type. */ 
  30. 'capability_type' => 'page',  
  31. 'map_meta_cap' => true,  
  32. 'menu_position' => 20,  
  33. 'hierarchical' => true,  
  34. 'rewrite' => false,  
  35. 'query_var' => false,  
  36. 'delete_with_user' => true,  
  37. 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),  
  38. 'show_in_rest' => true,  
  39. 'rest_base' => 'pages',  
  40. 'rest_controller_class' => 'WP_REST_Posts_Controller',  
  41. ) ); 
  42.  
  43. register_post_type( 'attachment', array( 
  44. 'labels' => array( 
  45. 'name' => _x('Media', 'post type general name'),  
  46. 'name_admin_bar' => _x( 'Media', 'add new from admin bar' ),  
  47. 'add_new' => _x( 'Add New', 'add new media' ),  
  48. 'edit_item' => __( 'Edit Media' ),  
  49. 'view_item' => __( 'View Attachment Page' ),  
  50. 'attributes' => __( 'Attachment Attributes' ),  
  51. ),  
  52. 'public' => true,  
  53. 'show_ui' => true,  
  54. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  55. '_edit_link' => 'post.php?post=%d', /** internal use only. don't use this when registering your own post type. */ 
  56. 'capability_type' => 'post',  
  57. 'capabilities' => array( 
  58. 'create_posts' => 'upload_files',  
  59. ),  
  60. 'map_meta_cap' => true,  
  61. 'hierarchical' => false,  
  62. 'rewrite' => false,  
  63. 'query_var' => false,  
  64. 'show_in_nav_menus' => false,  
  65. 'delete_with_user' => true,  
  66. 'supports' => array( 'title', 'author', 'comments' ),  
  67. 'show_in_rest' => true,  
  68. 'rest_base' => 'media',  
  69. 'rest_controller_class' => 'WP_REST_Attachments_Controller',  
  70. ) ); 
  71. add_post_type_support( 'attachment:audio', 'thumbnail' ); 
  72. add_post_type_support( 'attachment:video', 'thumbnail' ); 
  73.  
  74. register_post_type( 'revision', array( 
  75. 'labels' => array( 
  76. 'name' => __( 'Revisions' ),  
  77. 'singular_name' => __( 'Revision' ),  
  78. ),  
  79. 'public' => false,  
  80. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  81. '_edit_link' => 'revision.php?revision=%d', /** internal use only. don't use this when registering your own post type. */ 
  82. 'capability_type' => 'post',  
  83. 'map_meta_cap' => true,  
  84. 'hierarchical' => false,  
  85. 'rewrite' => false,  
  86. 'query_var' => false,  
  87. 'can_export' => false,  
  88. 'delete_with_user' => true,  
  89. 'supports' => array( 'author' ),  
  90. ) ); 
  91.  
  92. register_post_type( 'nav_menu_item', array( 
  93. 'labels' => array( 
  94. 'name' => __( 'Navigation Menu Items' ),  
  95. 'singular_name' => __( 'Navigation Menu Item' ),  
  96. ),  
  97. 'public' => false,  
  98. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  99. 'hierarchical' => false,  
  100. 'rewrite' => false,  
  101. 'delete_with_user' => false,  
  102. 'query_var' => false,  
  103. ) ); 
  104.  
  105. register_post_type( 'custom_css', array( 
  106. 'labels' => array( 
  107. 'name' => __( 'Custom CSS' ),  
  108. 'singular_name' => __( 'Custom CSS' ),  
  109. ),  
  110. 'public' => false,  
  111. 'hierarchical' => false,  
  112. 'rewrite' => false,  
  113. 'query_var' => false,  
  114. 'delete_with_user' => false,  
  115. 'can_export' => true,  
  116. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  117. 'supports' => array( 'title', 'revisions' ),  
  118. 'capabilities' => array( 
  119. 'delete_posts' => 'edit_theme_options',  
  120. 'delete_post' => 'edit_theme_options',  
  121. 'delete_published_posts' => 'edit_theme_options',  
  122. 'delete_private_posts' => 'edit_theme_options',  
  123. 'delete_others_posts' => 'edit_theme_options',  
  124. 'edit_post' => 'edit_css',  
  125. 'edit_posts' => 'edit_css',  
  126. 'edit_others_posts' => 'edit_css',  
  127. 'edit_published_posts' => 'edit_css',  
  128. 'read_post' => 'read',  
  129. 'read_private_posts' => 'read',  
  130. 'publish_posts' => 'edit_theme_options',  
  131. ),  
  132. ) ); 
  133.  
  134. register_post_type( 'customize_changeset', array( 
  135. 'labels' => array( 
  136. 'name' => _x( 'Changesets', 'post type general name' ),  
  137. 'singular_name' => _x( 'Changeset', 'post type singular name' ),  
  138. 'menu_name' => _x( 'Changesets', 'admin menu' ),  
  139. 'name_admin_bar' => _x( 'Changeset', 'add new on admin bar' ),  
  140. 'add_new' => _x( 'Add New', 'Customize Changeset' ),  
  141. 'add_new_item' => __( 'Add New Changeset' ),  
  142. 'new_item' => __( 'New Changeset' ),  
  143. 'edit_item' => __( 'Edit Changeset' ),  
  144. 'view_item' => __( 'View Changeset' ),  
  145. 'all_items' => __( 'All Changesets' ),  
  146. 'search_items' => __( 'Search Changesets' ),  
  147. 'not_found' => __( 'No changesets found.' ),  
  148. 'not_found_in_trash' => __( 'No changesets found in Trash.' ),  
  149. ),  
  150. 'public' => false,  
  151. '_builtin' => true, /** internal use only. don't use this when registering your own post type. */ 
  152. 'map_meta_cap' => true,  
  153. 'hierarchical' => false,  
  154. 'rewrite' => false,  
  155. 'query_var' => false,  
  156. 'can_export' => false,  
  157. 'delete_with_user' => false,  
  158. 'supports' => array( 'title', 'author' ),  
  159. 'capability_type' => 'customize_changeset',  
  160. 'capabilities' => array( 
  161. 'create_posts' => 'customize',  
  162. 'delete_others_posts' => 'customize',  
  163. 'delete_post' => 'customize',  
  164. 'delete_posts' => 'customize',  
  165. 'delete_private_posts' => 'customize',  
  166. 'delete_published_posts' => 'customize',  
  167. 'edit_others_posts' => 'customize',  
  168. 'edit_post' => 'customize',  
  169. 'edit_posts' => 'customize',  
  170. 'edit_private_posts' => 'customize',  
  171. 'edit_published_posts' => 'do_not_allow',  
  172. 'publish_posts' => 'customize',  
  173. 'read' => 'read',  
  174. 'read_post' => 'customize',  
  175. 'read_private_posts' => 'customize',  
  176. ),  
  177. ) ); 
  178.  
  179. register_post_status( 'publish', array( 
  180. 'label' => _x( 'Published', 'post status' ),  
  181. 'public' => true,  
  182. '_builtin' => true, /** internal use only. */ 
  183. 'label_count' => _n_noop( 'Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>' ),  
  184. ) ); 
  185.  
  186. register_post_status( 'future', array( 
  187. 'label' => _x( 'Scheduled', 'post status' ),  
  188. 'protected' => true,  
  189. '_builtin' => true, /** internal use only. */ 
  190. 'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>' ),  
  191. ) ); 
  192.  
  193. register_post_status( 'draft', array( 
  194. 'label' => _x( 'Draft', 'post status' ),  
  195. 'protected' => true,  
  196. '_builtin' => true, /** internal use only. */ 
  197. 'label_count' => _n_noop( 'Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>' ),  
  198. ) ); 
  199.  
  200. register_post_status( 'pending', array( 
  201. 'label' => _x( 'Pending', 'post status' ),  
  202. 'protected' => true,  
  203. '_builtin' => true, /** internal use only. */ 
  204. 'label_count' => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>' ),  
  205. ) ); 
  206.  
  207. register_post_status( 'private', array( 
  208. 'label' => _x( 'Private', 'post status' ),  
  209. 'private' => true,  
  210. '_builtin' => true, /** internal use only. */ 
  211. 'label_count' => _n_noop( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>' ),  
  212. ) ); 
  213.  
  214. register_post_status( 'trash', array( 
  215. 'label' => _x( 'Trash', 'post status' ),  
  216. 'internal' => true,  
  217. '_builtin' => true, /** internal use only. */ 
  218. 'label_count' => _n_noop( 'Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>' ),  
  219. 'show_in_admin_status_list' => true,  
  220. ) ); 
  221.  
  222. register_post_status( 'auto-draft', array( 
  223. 'label' => 'auto-draft',  
  224. 'internal' => true,  
  225. '_builtin' => true, /** internal use only. */ 
  226. ) ); 
  227.  
  228. register_post_status( 'inherit', array( 
  229. 'label' => 'inherit',  
  230. 'internal' => true,  
  231. '_builtin' => true, /** internal use only. */ 
  232. 'exclude_from_search' => false,  
  233. ) );