Created
January 13, 2016 20:53
-
-
Save brojask/ad76ef54b338b55ea655 to your computer and use it in GitHub Desktop.
MULTIPLE CUSTOM POST TYPE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ADDING CUSTOM POST TYPE | |
add_action('init', 'all_custom_post_types'); | |
function all_custom_post_types() { | |
$types = array( | |
// News and Events | |
array('the_type' => 'news-and-events', 'single' => 'News and Events', 'plural' => 'News and Events'), | |
// Careers | |
array('the_type' => 'careers', 'single' => 'Career', 'plural' => 'Careers'), | |
// Faculty | |
array('the_type' => 'faculty', 'single' => 'Faculty', 'plural' => 'Faculty')); | |
foreach ($types as $type) { | |
$the_type = $type['the_type']; | |
$single = $type['single']; | |
$plural = $type['plural']; | |
$labels = array('name' => _x($plural, 'post type general name'), 'singular_name' => _x($single, 'post type singular name'), 'add_new' => _x('Add New', $single), 'add_new_item' => __('Add New ' . $single), 'edit_item' => __('Edit ' . $single), 'new_item' => __('New ' . $single), 'view_item' => __('View ' . $single), 'search_items' => __('Search ' . $plural), 'not_found' => __('No ' . $plural . ' found'), 'not_found_in_trash' => __('No ' . $plural . ' found in Trash'), 'parent_item_colon' => ''); | |
$args = array('labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'hierarchical' => false, 'menu_position' => 5, 'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')); | |
register_post_type($the_type, $args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment