Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Hierarchical custom post type - can't specify parent

By: a guest on Dec 21st, 2010  |  syntax: PHP  |  size: 2.13 KB  |  views: 921  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /* Register Custom Post Type for CD */
  3. add_action('init', 'cd_post_type_init');
  4. function cd_post_type_init() {
  5.   $labels = array(
  6.     'name' => _x('CD', 'post type general name'),
  7.     'singular_name' => _x('cd', 'post type singular name'),
  8.     'add_new' => _x('Add New', 'CD'),
  9.     'add_new_item' => __('Add New CD'),
  10.     'edit_item' => __('Edit CD'),
  11.     'new_item' => __('New CD'),
  12.     'view_item' => __('View CD'),
  13.     'search_items' => __('Search CDs'),
  14.     'not_found' =>  __('No CDs found'),
  15.     'not_found_in_trash' => __('No CDs found in Trash'),
  16.     'parent_item_colon' => ''
  17.   );
  18.   $args = array(
  19.     'labels' => $labels,
  20.     'public' => true,
  21.     'publicly_queryable' => true,
  22.     'show_ui' => true,
  23.     'rewrite' => true,
  24.     'query_var' => true,
  25.     'capability_type' => 'post',
  26.     'hierarchical' => false,
  27.     'show_in_nav_menus' => false,
  28.     'menu_position' => 1000,
  29.     'supports' => array(
  30.       'title',    
  31.     )
  32.   );
  33.   register_post_type('cd',$args);
  34. }
  35.  
  36. /* Register Custom Post Type for Track */
  37. add_action('init', 'track_post_type_init');
  38. function track_post_type_init() {
  39.   $labels = array(
  40.     'name' => _x('Track', 'post type general name'),
  41.     'singular_name' => _x('Track', 'post type singular name'),
  42.     'add_new' => _x('Add New', 'Track'),
  43.     'add_new_item' => __('Add New Track'),
  44.     'edit_item' => __('Edit Track'),
  45.     'new_item' => __('New Track'),
  46.     'view_item' => __('View Track'),
  47.     'search_items' => __('Search Tracks'),
  48.     'not_found' =>  __('No Tracks found'),
  49.     'not_found_in_trash' => __('No Tracks found in Trash'),
  50.     'parent_item_colon' => __('CD'),
  51.         'parent' => __('CD'),
  52.   );
  53.   $args = array(
  54.     'labels' => $labels,
  55.     'public' => true,
  56.     'publicly_queryable' => true,
  57.     'show_ui' => true, //false - to hide from the admin area menu
  58.     'rewrite' => true,
  59.     'query_var' => true,
  60.     'capability_type' => 'post',
  61.     'hierarchical' => true, //allow parent pages
  62.     'show_in_nav_menus' => false,
  63.     'menu_position' => 1000,
  64.     'supports' => array(
  65.       'title',
  66.           'page-attributes'
  67.     )
  68.   );
  69.   register_post_type('track',$args);
  70. }
  71. ?>