Created
October 5, 2018 18:19
-
-
Save tessak22/8b0d4bdad280909a1d33b6b0d5cbda9b to your computer and use it in GitHub Desktop.
Dogs Custom Post Type
This file contains 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
// Custom Post Types | |
add_action('init', 'tessak22_register_custom_post_types', 0); | |
function tessak22_register_custom_post_types() | |
{ | |
$arr_custom_post_type_options = array( | |
/* | |
array( | |
'label' => 'lowercase_name' // ** 20 char max, no spaces or caps | |
'singlar' => 'Human-Readable Item' // singular name | |
'plural' => 'Human-Readable Items' // plural name | |
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats') | |
), | |
*/ | |
array( | |
'label' => 'dogs', | |
'singular' => 'Dog', | |
'plural' => 'Dogs', | |
'supports' => array('title','editor', 'custom-fields', 'page-attributes'), | |
'icon' => 'dashicons-heart', | |
), | |
); | |
foreach ($arr_custom_post_type_options as $cpt_opts) { | |
$label = $cpt_opts['label']; | |
$labels = array( | |
'name' => $cpt_opts['plural'], | |
'singular_name' => $cpt_opts['singular'], | |
'menu_name' => $cpt_opts['plural'], | |
'parent_item_colon' => 'Parent:', | |
'all_items' => $cpt_opts['plural'], | |
'view_item' => 'View', | |
'add_new_item' => 'Add New', | |
'add_new' => 'Add New', | |
'edit_item' => 'Edit', | |
'update_item' => 'Update', | |
'search_items' => 'Search ' . $cpt_opts['plural'], | |
'not_found' => 'None found', | |
'not_found_in_trash' => 'None found in Trash', | |
); | |
$args = array( | |
'label' => $label, | |
'description' => 'Custom Post Type: ' . $cpt_opts['plural'], | |
'labels' => $labels, | |
'supports' => $cpt_opts['supports'], | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'menu_position' => 25.3, | |
'menu_icon' => $cpt_opts['icon'], | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => false, | |
'publicly_queryable' => true, | |
'rewrite' => true, | |
'capability_type' => 'post', | |
); | |
register_post_type($label, $args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment