create_initial_taxonomies

Creates the initial taxonomies.

Description

create_initial_taxonomies(); 

This function fires twice: in wp-settings.php before plugins are loaded (for backward compatibility reasons), and again on the action. We must avoid registering rewrite rules before the action.


Usage

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

Defined (1)

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

/wp-includes/taxonomy.php  
  1. function create_initial_taxonomies() { 
  2. global $wp_rewrite; 
  3.  
  4. if ( ! did_action( 'init' ) ) { 
  5. $rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false ); 
  6. } else { 
  7.  
  8. /** 
  9. * Filters the post formats rewrite base. 
  10. * @since 3.1.0 
  11. * @param string $context Context of the rewrite base. Default 'type'. 
  12. */ 
  13. $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' ); 
  14. $rewrite = array( 
  15. 'category' => array( 
  16. 'hierarchical' => true,  
  17. 'slug' => get_option('category_base') ? get_option('category_base') : 'category',  
  18. 'with_front' => ! get_option('category_base') || $wp_rewrite->using_index_permalinks(),  
  19. 'ep_mask' => EP_CATEGORIES,  
  20. ),  
  21. 'post_tag' => array( 
  22. 'hierarchical' => false,  
  23. 'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag',  
  24. 'with_front' => ! get_option('tag_base') || $wp_rewrite->using_index_permalinks(),  
  25. 'ep_mask' => EP_TAGS,  
  26. ),  
  27. 'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false,  
  28. ); 
  29.  
  30. register_taxonomy( 'category', 'post', array( 
  31. 'hierarchical' => true,  
  32. 'query_var' => 'category_name',  
  33. 'rewrite' => $rewrite['category'],  
  34. 'public' => true,  
  35. 'show_ui' => true,  
  36. 'show_admin_column' => true,  
  37. '_builtin' => true,  
  38. 'capabilities' => array( 
  39. 'manage_terms' => 'manage_categories',  
  40. 'edit_terms' => 'edit_categories',  
  41. 'delete_terms' => 'delete_categories',  
  42. 'assign_terms' => 'assign_categories',  
  43. ),  
  44. 'show_in_rest' => true,  
  45. 'rest_base' => 'categories',  
  46. 'rest_controller_class' => 'WP_REST_Terms_Controller',  
  47. ) ); 
  48.  
  49. register_taxonomy( 'post_tag', 'post', array( 
  50. 'hierarchical' => false,  
  51. 'query_var' => 'tag',  
  52. 'rewrite' => $rewrite['post_tag'],  
  53. 'public' => true,  
  54. 'show_ui' => true,  
  55. 'show_admin_column' => true,  
  56. '_builtin' => true,  
  57. 'capabilities' => array( 
  58. 'manage_terms' => 'manage_post_tags',  
  59. 'edit_terms' => 'edit_post_tags',  
  60. 'delete_terms' => 'delete_post_tags',  
  61. 'assign_terms' => 'assign_post_tags',  
  62. ),  
  63. 'show_in_rest' => true,  
  64. 'rest_base' => 'tags',  
  65. 'rest_controller_class' => 'WP_REST_Terms_Controller',  
  66. ) ); 
  67.  
  68. register_taxonomy( 'nav_menu', 'nav_menu_item', array( 
  69. 'public' => false,  
  70. 'hierarchical' => false,  
  71. 'labels' => array( 
  72. 'name' => __( 'Navigation Menus' ),  
  73. 'singular_name' => __( 'Navigation Menu' ),  
  74. ),  
  75. 'query_var' => false,  
  76. 'rewrite' => false,  
  77. 'show_ui' => false,  
  78. '_builtin' => true,  
  79. 'show_in_nav_menus' => false,  
  80. ) ); 
  81.  
  82. register_taxonomy( 'link_category', 'link', array( 
  83. 'hierarchical' => false,  
  84. 'labels' => array( 
  85. 'name' => __( 'Link Categories' ),  
  86. 'singular_name' => __( 'Link Category' ),  
  87. 'search_items' => __( 'Search Link Categories' ),  
  88. 'popular_items' => null,  
  89. 'all_items' => __( 'All Link Categories' ),  
  90. 'edit_item' => __( 'Edit Link Category' ),  
  91. 'update_item' => __( 'Update Link Category' ),  
  92. 'add_new_item' => __( 'Add New Link Category' ),  
  93. 'new_item_name' => __( 'New Link Category Name' ),  
  94. 'separate_items_with_commas' => null,  
  95. 'add_or_remove_items' => null,  
  96. 'choose_from_most_used' => null,  
  97. ),  
  98. 'capabilities' => array( 
  99. 'manage_terms' => 'manage_links',  
  100. 'edit_terms' => 'manage_links',  
  101. 'delete_terms' => 'manage_links',  
  102. 'assign_terms' => 'manage_links',  
  103. ),  
  104. 'query_var' => false,  
  105. 'rewrite' => false,  
  106. 'public' => false,  
  107. 'show_ui' => true,  
  108. '_builtin' => true,  
  109. ) ); 
  110.  
  111. register_taxonomy( 'post_format', 'post', array( 
  112. 'public' => true,  
  113. 'hierarchical' => false,  
  114. 'labels' => array( 
  115. 'name' => _x( 'Format', 'post format' ),  
  116. 'singular_name' => _x( 'Format', 'post format' ),  
  117. ),  
  118. 'query_var' => true,  
  119. 'rewrite' => $rewrite['post_format'],  
  120. 'show_ui' => false,  
  121. '_builtin' => true,  
  122. 'show_in_nav_menus' => current_theme_supports( 'post-formats' ),  
  123. ) );