Last active
August 10, 2018 20:27
-
-
Save ridinghoodmedia/4f099c780b81e077127ed25f3858135a to your computer and use it in GitHub Desktop.
Create 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
<?php | |
/** | |
* Participant class | |
*/ | |
class Participant | |
{ | |
public function __construct() | |
{ | |
// Register post type with WP | |
add_action('init', [$this, 'addPostType']); | |
} | |
public function addPostType() | |
{ | |
$labels = [ | |
'name' => _x('Participants', 'post type general name'), | |
'singular_name' => _x('Participant', 'post type singular name'), | |
'add_new' => _x('Add New', 'Participant'), | |
'add_new_item' => __('Add New Participant'), | |
'edit_item' => __('Edit Participant'), | |
'new_item' => __('New Participant'), | |
'all_items' => __('All Participants'), | |
'view_item' => __('View Participant'), | |
'search_items' => __('Search participants'), | |
'not_found' => __('No participants found'), | |
'not_found_in_trash' => __('No participants found in the Trash'), | |
'parent_item_colon' => '', | |
'menu_name' => 'Participants' | |
]; | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Participants description', | |
'public' => true, | |
'menu_position' => 3, | |
'supports' => array('title'), | |
'has_archive' => true, | |
); | |
register_post_type('participant', $args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment