Last active
December 21, 2023 18:21
-
-
Save wpflames/2b581b0551a2480e5b77d1f93cea1ea9 to your computer and use it in GitHub Desktop.
Create a Custom Post Type in WordPress
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
<?php | |
function custom_post_types() { | |
// Events | |
register_post_type('event', array( | |
'public' => true, | |
'capability_type' => 'event', | |
'map_meta_cap' => true, | |
'show_in_rest' => true, | |
'has_archive' => true, | |
'supports' => array( 'title', 'editor', 'thumbnail'), | |
'rewrite' => array('slug' => 'events'), | |
'labels' => array( | |
'name' => 'Events', | |
'add_new_item' => 'Add New Event', | |
'edit_item' => 'Edit Event', | |
'all_items' => 'All Events', | |
'singular_name' => 'Event', | |
), | |
'menu_icon' => 'dashicons-calendar' | |
)); | |
} | |
add_action('init', 'custom_post_types'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment