Advertisement
Guest User

custom post type

a guest
Nov 27th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.44 KB | None | 0 0
  1. add_action( 'init', 'films_register' );
  2. function films_register() {
  3. register_post_type( 'films',
  4. array(
  5. 'labels' => array(
  6. 'name' => 'Films',
  7. 'singular_name' => 'Film',
  8. 'add_new' => 'Add New',
  9. 'add_new_item' => 'Add New Film',
  10. 'edit' => 'Edit',
  11. 'edit_item' => 'Edit Film',
  12. 'new_item' => 'New Film',
  13. 'view' => 'View',
  14. 'view_item' => 'View Film',
  15. 'search_items' => 'Search Film',
  16. 'not_found' => 'No Movies found',
  17. 'not_found_in_trash' => 'No Movies found in Trash',
  18. 'parent' => 'Parent Film'
  19. ),
  20.  
  21. 'public' => true,
  22. //'publicly_queryable' => true,
  23. //'capability_type' => 'post',
  24. //'query_var' => true,
  25. 'menu_position' => 15,
  26. 'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields', 'excerpt', 'trackbacks' ),
  27. 'show_ui' => true,
  28. 'menu_icon' => plugins_url( 'images/image.png', __FILE__ ),
  29. 'has_archive' => true,
  30. 'rewrite' => array( 'slug' => 'films' ),
  31. )
  32. );
  33. }
  34. add_action('admin_init', 'flush_rewrite_rules');
  35. function create_films_taxonomies()
  36. {
  37. //Add new taxonomy, Genre
  38. $labels = array(
  39. 'name' => _x( 'Genres', 'taxonomy general name' ),
  40. 'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
  41. 'search_items' => __( 'Search Genres' ),
  42. 'all_items' => __( 'All Genres' ),
  43. 'parent_item' => __( 'Parent Genre' ),
  44. 'parent_item_colon' => __( 'Parent Genre:' ),
  45. 'edit_item' => __( 'Edit Genre' ),
  46. 'update_item' => __( 'Update Genre' ),
  47. 'add_new_item' => __( 'Add New Genre' ),
  48. 'new_item_name' => __( 'New Genre Name' ),
  49. 'menu_name' => __( 'Genres' )
  50. );
  51.  
  52. $args = array(
  53. 'public' => true,
  54. 'hierarchical' => true,
  55. 'labels' => $labels,
  56. 'show_ui' => true,
  57. 'show_admin_column' => true,
  58. 'query_var' => true,
  59. 'rewrite' => array( 'slug' => 'films/genre' )
  60.  
  61. );
  62. register_taxonomy( 'genre', array( 'films' ), $args );
  63.  
  64. // Add new taxonomy, Topics
  65. $labels = array(
  66. 'name' => _x( 'Topic', 'taxonomy general name' ),
  67. 'singular_name' => _x( 'Topics', 'taxonomy singular name' ),
  68. 'search_items' => __( 'Search Topic' ),
  69. 'all_items' => __( 'All Topics' ),
  70. 'parent_item' => __( 'Parent Topic' ),
  71. 'parent_item_colon' => __( 'Parent Topic:' ),
  72. 'edit_item' => __( 'Edit Topic' ),
  73. 'update_item' => __( 'Update Topic' ),
  74. 'add_new_item' => __( 'Add New Topic' ),
  75. 'new_item_name' => __( 'New Topic Name' ),
  76. 'menu_name' => __( 'Topics' )
  77. );
  78.  
  79. $args = array(
  80. 'public' => true,
  81. 'labels' => $labels,
  82. 'show_ui' => true,
  83. 'show_admin_column' => true,
  84. 'query_var' => true,
  85. 'rewrite' => array( 'slug' => 'films/topic' ),
  86. 'hierarchical' => false
  87. );
  88. register_taxonomy( 'topics', array( 'films' ), $args );
  89.  
  90. // Add new taxonomy, Collections
  91. $labels = array(
  92. 'name' => _x( 'Collections', 'taxonomy general name' ),
  93. 'singular_name' => _x( 'Collection', 'taxonomy singular name' ),
  94. 'search_items' => __( 'Search Collections' ),
  95. 'all_items' => __( 'All Collections' ),
  96. 'parent_item' => __( 'Parent Collection' ),
  97. 'parent_item_colon' => __( 'Parent Collection:' ),
  98. 'edit_item' => __( 'Edit Collection' ),
  99. 'update_item' => __( 'Update Collection' ),
  100. 'add_new_item' => __( 'Add New Collection' ),
  101. 'new_item_name' => __( 'New Collection Name' ),
  102. 'menu_name' => __( 'Collections' )
  103. );
  104.  
  105. $args = array(
  106. 'public' => true,
  107. 'hierarchical' => false,
  108. 'labels' => $labels,
  109. 'show_ui' => true,
  110. 'show_admin_column' => true,
  111. 'query_var' => true,
  112. 'rewrite' => array( 'slug' => 'collection' )
  113. );
  114. register_taxonomy( 'collection', array( 'films' ), $args );
  115.  
  116. }
  117. add_action( 'init', 'create_films_taxonomies', 0 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement