darrenbachan

wp-games-cpt.php

Jun 12th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.23 KB | None | 0 0
  1. <?php
  2.  
  3. function dbwp_register_post_type() {
  4.  
  5.         $singular = 'Upcoming Game';
  6.         $plural = 'Upcoming Games';
  7.  
  8.         $labels = array(
  9.                 'name'                  => $plural,
  10.                 'singular'              => $singular,
  11.                 'add_name'              => 'Add New',
  12.                 'add_new_item'          => 'Add New  ' . $singular,
  13.                 'edit'                  => 'Edit',
  14.                 'edit_item'             => 'Edit ' . $singular,
  15.                 'new_item'              => 'New ' . $singular,
  16.                 'view'                  => 'View ' . $singular,
  17.                 'view_item'             => 'View ' . $singular,
  18.                 'search_term'           => 'Search ' . $plural,
  19.                 'parent'                => 'Parent ' . $singular,
  20.                 'not_found'             => 'No ' . $plural . ' found',
  21.                 'not_found_in_trash'    => 'No ' . $plural . ' in Trash'
  22.         );
  23.  
  24.         $args = array(
  25.                 'labels'                => $labels,
  26.                 'public'                => true,
  27.                 'publicly_queryable'    => true, //true
  28.                 'exclude_from_search'   => false, //false
  29.                 'show_in_nav_menus'     => true,
  30.                 'show_ui'               => true,
  31.                 'show_in_menu'          => true,
  32.                 'show_in_admin_bar'     => true,
  33.                 'menu_position'         => 6,
  34.                 'menu_icon'             => 'dashicons-megaphone',
  35.                 'can_export'            => true,
  36.                 'delete_with_user'      => false,
  37.                 'hierarchical'          => false,
  38.                 'has_archive'           => true,
  39.                 'query_var'             => true,
  40.                 'capability_type'       => 'page',
  41.                 'map_meta_cap'          => true,
  42.                 // 'capabilities' => array(),
  43.                 'rewrite'               => array(
  44.                         'slug'                  => 'upcoming-games',
  45.                         'with_front'            => false,
  46.                         'pages'                 => true,
  47.                         'feeds'                 => false,
  48.                         ),
  49.                 'supports'              => array(
  50.                         'title',
  51.                         'editor',
  52.                         'author',
  53.                         'thumbnail',
  54.                         'custom-fields',
  55.                         'comments',
  56.                         'revisions'
  57.                 )
  58.         );
  59.  
  60.         register_post_type('upcoming-games', $args);
  61.  
  62. }
  63. add_action('init', 'dbwp_register_post_type');
  64.  
  65. function dbwp_register_category_taxonomy() {
  66.  
  67.         $plural = 'Consoles';
  68.         $single = 'Console';
  69.  
  70.         $labels = array(
  71.                 'name'                      => $plural,
  72.                 'singular_name'             => $singular,
  73.                 'search_items'              => 'Search ' . $plural,
  74.                 'popular_items'             => 'Popular ' . $plural,
  75.                 'all_items'                 => 'All ' . $plural,
  76.                 'parent_item'               => null,
  77.                 'parent_item_colon'         => null,
  78.                 'edit_item'                 => 'Edit ' . $singular,
  79.                 'update_item'               => 'Update ' . $singular,
  80.                 'add_new_item'              => 'Add New ' . $singular,
  81.                 'new_item_name'             => 'New ' . $singular . ' Name',
  82.                 'separate_items_with_commas'=> 'Separate ' . $plural . ' with commas',
  83.                 'add_or_remove_items'       => 'Add or remove ' . $plural,
  84.                 'choose_from_most_used'     => 'Choose from the most used ' . $plural,
  85.                 'not_found'                 => 'No ' . $plural . ' found.',
  86.                 'menu_name'                 => $plural,
  87.         );
  88.  
  89.         $args = array(
  90.                 'hierarchical'          => true,
  91.                 'labels'                => $labels,
  92.                 'show_ui'               => true,
  93.                 'show_admin_column'     => true,
  94.                 'update_count_callback' => '_update_post_term_count',
  95.                 'query var'             => true,
  96.                 'rewrite'               => array( 'slug' => 'consoles'
  97.                 )
  98.         );
  99.         register_taxonomy('consoles', 'upcoming-games', $args);
  100.  
  101. }
  102. add_action('init', 'dbwp_register_category_taxonomy');
  103.  
  104. function dbwp_register_tag_taxonomy() {
  105.  
  106.         $plural = 'Genres';
  107.         $single = 'Genre';
  108.  
  109.         $labels = array(
  110.                 'name'                      => $plural,
  111.                 'singular_name'             => $singular,
  112.                 'search_items'              => 'Search ' . $plural,
  113.                 'popular_items'             => 'Popular ' . $plural,
  114.                 'all_items'                 => 'All ' . $plural,
  115.                 'parent_item'               => null,
  116.                 'parent_item_colon'         => null,
  117.                 'edit_item'                 => 'Edit ' . $singular,
  118.                 'update_item'               => 'Update ' . $singular,
  119.                 'add_new_item'              => 'Add New ' . $singular,
  120.                 'new_item_name'             => 'New ' . $singular . ' Name',
  121.                 'separate_items_with_commas'=> 'Separate ' . $plural . ' with commas',
  122.                 'add_or_remove_items'       => 'Add or remove ' . $plural,
  123.                 'choose_from_most_used'     => 'Choose from the most used ' . $plural,
  124.                 'not_found'                 => 'No ' . $plural . ' found.',
  125.                 'menu_name'                 => $plural,
  126.         );
  127.  
  128.         $args = array(
  129.                 'hierarchical'          => false,
  130.                 'labels'                => $labels,
  131.                 'show_ui'               => true,
  132.                 'show_admin_column'     => true,
  133.                 'update_count_callback' => '_update_post_term_count',
  134.                 'query var'             => true,
  135.                 'rewrite'               => array( 'slug' => 'genres'
  136.                 )
  137.         );
  138.         register_taxonomy('genres', 'upcoming-games', $args);
  139.  
  140. }
  141. add_action('init', 'dbwp_register_tag_taxonomy');
Add Comment
Please, Sign In to add comment