Guest User

Untitled

a guest
Jun 19th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. // ADDING CUSTOM POST TYPE
  2. add_action('init', 'all_custom_post_types');
  3.  
  4. function all_custom_post_types() {
  5.  
  6. $types = array(
  7.  
  8. // News and Events
  9. array('the_type' => 'premier-league',
  10. 'single' => 'Fantasty Premier league',
  11. 'plural' => 'Fantasty Premier league'),
  12.  
  13. // Careers
  14. array('the_type' => 'champions_league',
  15. 'single' => 'Champions league',
  16. 'plural' => 'Champions league'),
  17.  
  18. // Faculty
  19. array('the_type' => 'daily-football',
  20. 'single' => 'Daily fantasy football',
  21. 'plural' => 'Daily fantasy football')
  22.  
  23. );
  24.  
  25. foreach ($types as $type) {
  26.  
  27. $the_type = $type['the_type'];
  28. $single = $type['single'];
  29. $plural = $type['plural'];
  30.  
  31. $labels = array(
  32. 'name' => _x($plural, 'post type general name'),
  33. 'singular_name' => _x($single, 'post type singular name'),
  34. 'all_items' => __( 'All '.$single.' posts'),
  35. 'add_new' => _x('Add New', $single),
  36. 'add_new_item' => __('Add New '. $single),
  37. 'edit_item' => __('Edit '.$single),
  38. 'new_item' => __('New '.$single),
  39. 'view_item' => __('View '.$single),
  40. 'search_items' => __('Search '.$plural),
  41. 'not_found' => __('No '.$plural.' found'),
  42. 'not_found_in_trash' => __('No '.$plural.' found in Trash'),
  43. 'parent_item_colon' => ''
  44. );
  45.  
  46. $args = array(
  47. 'labels' => $labels,
  48. 'public' => true,
  49. 'publicly_queryable' => true,
  50. 'show_ui' => true,
  51. 'query_var' => true,
  52. 'rewrite' => true,
  53. 'capability_type' => 'post',
  54. 'hierarchical' => false,
  55. 'taxonomies' => array( 'category', 'post_tag' ),
  56. 'menu_position' => 5,
  57. 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
  58. );
  59.  
  60. register_post_type($the_type, $args);
  61.  
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment