Create A New Custom Post Type “Programs”

Remember to register it under the mu-plugins/custom_post_types.php All page looks like this now:

<?php

//Create New Post Type Here
function custom_post_types(){

    //Register Event Post Type
    register_post_type('event', array(       
        //All this is Front End Page
        //this will rewrite slug from singular to plural when url /events/ instead of /event/
        'rewrite' => array('slug' => 'events'),
        //This will add functionality to the permalink etc
        'has_archive' => true,
        //All this is Admin
        //Make it public
        'public' => true,
        //Add Title Editor and Excerpt to new page. Add editor to activate modern editor also show_in_rest should be addressed. check below
        //Real Custom Fields Shown Could be here
        //'supports' => array('title', 'editor', 'excerpt', 'custom-fields'),
        'supports' => array('title', 'editor', 'excerpt'),
        //Make it be edited on new "Block" gutenmberg conf
        'show_in_rest' => true,        
        //Admin Left Navigation Label here
        'labels' => array(
            //Name of Admin title on Nav
            'name' => 'Events',
            // //Name of Add new on dropdown
            'add_new' => 'Add New Event',            
            // //Name of Add new event when posting
            'add_new_item' => 'Add New Event',
            // 'edit_item' => 'Edit Event',
            // //menu item All Events link
            'all_items' => 'All Events',
            'singular_name' => 'Event'
        ),
        //Admin Icon Label
        'menu_icon' => 'dashicons-calendar'
    ));

    //Register Event Post Type
    register_post_type('program', array(  
        'show_in_rest' => true,
        'supports' => array('title', 'editor'), 
        'rewrite' => array('slug' => 'programs'),            
        'has_archive' => true,
        'public' => true,
        'labels' => array(
            'name' => 'Programs',
            'add_new' => 'Add New Program',            
            'add_new_item' => 'Add New Programs',
            'edit_item' => 'Edit Program',
            'all_items' => 'All Programs',
            'singular_name' => 'Program'
        ),
        'menu_icon' => 'dashicons-awards'
    ));

}
add_action('init', 'custom_post_types');

REMEMBER TO SAVE IN PERMALINK SO URL SHOWS UP!!!!!!!!!!

Scroll to Top