Advertisement
hmbashar

Custom Post with 3 Taxonomy

Oct 24th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1.  
  2. function cb_result_custom_post() {
  3.    
  4. // Register Custom Post
  5. register_post_type( 'results',
  6.         array(
  7.                 'labels' => array(
  8.                         'name' => __( 'Results' ),
  9.                         'singular_name' => __( 'Result' ),
  10.                         'add_new' => __( 'Add New' ),
  11.                         'add_new_item' => __( 'Add New Result' ),
  12.                         'edit_item' => __( 'Edit Result' ),
  13.                         'new_item' => __( 'New Result' ),
  14.                         'view_item' => __( 'View Result' ),
  15.                         'not_found' => __( 'Sorry, we couldn\'t find the Result you are looking for.' )
  16.                 ),
  17.         'public' => true,
  18.         'publicly_queryable' => false,
  19.         'exclude_from_search' => true,
  20.         'menu_position' => 14,
  21.         'has_archive' => true,
  22.         'hierarchical' => false,
  23.         'capability_type' => 'page',
  24.         'rewrite' => array( 'slug' => 'cb_result' ),
  25.         'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' )
  26.         )
  27. );
  28.  
  29.  
  30. //Register Custom Taxonomy
  31. register_taxonomy(
  32.     'cb_result_year',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  33.     'results',                  //post type name
  34.     array(
  35.         'hierarchical'          => true,
  36.         'label'                         => 'Years',  //Display name
  37.         'query_var'             => true,
  38.         'show_admin_column'             => true,
  39.         'rewrite'                       => array(
  40.             'slug'                  => 'cb_result_year', // This controls the base slug that will display before each term
  41.             'with_front'    => true // Don't display the category base before
  42.             )
  43.         )
  44. );
  45.  
  46. register_taxonomy(
  47.     'cb_result_class',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  48.     'results',                  //post type name
  49.     array(
  50.         'hierarchical'          => true,
  51.         'label'                         => 'Class',  //Display name
  52.         'query_var'             => true,
  53.         'show_admin_column'             => true,
  54.         'rewrite'                       => array(
  55.             'slug'                  => 'cb_result_class', // This controls the base slug that will display before each term
  56.             'with_front'    => true // Don't display the category base before
  57.             )
  58.         )
  59. );
  60.  
  61. register_taxonomy(
  62.     'cb_result_semester',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
  63.     'results',                  //post type name
  64.     array(
  65.         'hierarchical'          => true,
  66.         'label'                         => 'Semester',  //Display name
  67.         'query_var'             => true,
  68.         'show_admin_column'             => true,
  69.         'rewrite'                       => array(
  70.             'slug'                  => 'cb_result_semester', // This controls the base slug that will display before each term
  71.             'with_front'    => true // Don't display the category base before
  72.             )
  73.         )
  74. );
  75.  
  76.  
  77.  
  78. }
  79. add_action( 'init', 'cb_result_custom_post' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement