Advertisement
Guest User

CPT.php

a guest
Jul 21st, 2012
1,832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.28 KB | None | 0 0
  1. <?php
  2.  
  3. // Video Post type
  4.  
  5. add_action('init', 'video_register');
  6.  
  7. function video_register() {
  8.  
  9.     $labels = array(
  10.         'name' => _x('Videos', 'post type general name'),
  11.         'singular_name' => _x('Video', 'post type singular name'),
  12.         'add_new' => _x('Add New', 'video'),
  13.         'add_new_item' => __('Add New Video'),
  14.         'edit_item' => __('Edit Video'),
  15.         'new_item' => __('New Video'),
  16.         'view_item' => __('View Video'),
  17.         'search_items' => __('Search Video'),
  18.         'not_found' =>  __('Nothing found'),
  19.         'not_found_in_trash' => __('Nothing found in Trash'),
  20.         'parent_item_colon' => ''
  21.     );
  22.  
  23.     $args = array(
  24.         'labels' => $labels,
  25.         'public' => true,
  26.         'publicly_queryable' => true,
  27.         'show_ui' => true,
  28.         'query_var' => true,
  29.         'menu_icon' => null,
  30.         'rewrite' => true,
  31.         'capability_type' => 'post',
  32.         'hierarchical' => false,
  33.         'menu_position' => null,
  34.         'supports' => array('title','editor','thumbnail')
  35.       );
  36.  
  37.     register_post_type( 'video' , $args );
  38. }
  39.  
  40.  
  41. // Review Post type
  42.  
  43. add_action('init', 'review_register');
  44.  
  45. function review_register() {
  46.  
  47.     $labels = array(
  48.         'name' => _x('Reviews', 'post type general name'),
  49.         'singular_name' => _x('Review', 'post type singular name'),
  50.         'add_new' => _x('Add New', 'review'),
  51.         'add_new_item' => __('Add New Review'),
  52.         'edit_item' => __('Edit Review'),
  53.         'new_item' => __('New Review'),
  54.         'view_item' => __('View Review'),
  55.         'search_items' => __('Search Review'),
  56.         'not_found' =>  __('Nothing found'),
  57.         'not_found_in_trash' => __('Nothing found in Trash'),
  58.         'parent_item_colon' => ''
  59.     );
  60.  
  61.     $args = array(
  62.         'labels' => $labels,
  63.         'public' => true,
  64.         'publicly_queryable' => true,
  65.         'show_ui' => true,
  66.         'query_var' => true,
  67.         'menu_icon' => null,
  68.         'rewrite' => true,
  69.         'capability_type' => 'post',
  70.         'hierarchical' => false,
  71.         'menu_position' => null,
  72.         'supports' => array('title','editor','thumbnail')
  73.       );
  74.  
  75.     register_post_type( 'review' , $args );
  76. register_taxonomy_for_object_type( 'category', 'review' );
  77. }
  78.  
  79.  
  80.  
  81. // Custom Taxonomy
  82.  
  83. function add_console_taxonomies() {
  84.  
  85.     register_taxonomy('console', 'review', array(
  86.         // Hierarchical taxonomy (like categories)
  87.         'hierarchical' => true,
  88.         // This array of options controls the labels displayed in the WordPress Admin UI
  89.         'labels' => array(
  90.             'name' => _x( 'Review Category', 'taxonomy general name' ),
  91.             'singular_name' => _x( 'Review-Category', 'taxonomy singular name' ),
  92.             'search_items' =>  __( 'Search Review-Categories' ),
  93.             'all_items' => __( 'All Review-Categories' ),
  94.             'parent_item' => __( 'Parent Review-Category' ),
  95.             'parent_item_colon' => __( 'Parent Review-Category:' ),
  96.             'edit_item' => __( 'Edit Review-Category' ),
  97.             'update_item' => __( 'Update Review-Category' ),
  98.             'add_new_item' => __( 'Add New Review-Category' ),
  99.             'new_item_name' => __( 'New Review-Category Name' ),
  100.             'menu_name' => __( 'Review Categories' ),
  101.         ),
  102.         // Control the slugs used for this taxonomy
  103.         'rewrite' => array(
  104.             'slug' => 'reviews-online', // This controls the base slug that will display before each term
  105.             'with_front' => false, // Don't display the category base before "/locations/"
  106.             'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
  107.         ),
  108.     ));
  109. }
  110. add_action( 'init', 'add_console_taxonomies', 0 );
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement