Any Plugin that we create under this folder will be automatically called by wordpress.
Under wp-content folder, create mu-plugins folder
wp-content/mu-plugins
We can name the new file custom_post_types.php
And we will copy paste the registered custom post type that we previously added to functions.php
So custom_post_types.php looks like this now:
<?php
//Create New Post Type Here
function custom_post_types(){
register_post_type('event', array(
//This will add functionality to the permalink etc
'has_archive' => true,
//Make it public
'public' => true,
//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'
));
}
add_action('init', 'custom_post_types');
//Remember! no closing php tag here