Skip to content

Instantly share code, notes, and snippets.

@dougdaulton
Created March 7, 2016 03:38
Show Gist options
  • Save dougdaulton/406ad28e49823926024d to your computer and use it in GitHub Desktop.
Save dougdaulton/406ad28e49823926024d to your computer and use it in GitHub Desktop.
/*********************************************
Contests CPT
**********************************************/
/* Contest CPT :: Initiate CPT
**********************************************/
function be_register_contest_post_type() {
$labels = array(
'name' => 'Contests',
'singular_name' => 'Contest',
'add_new' => 'Add New',
'add_new_item' => 'Add New Contest',
'edit_item' => 'Edit Contest',
'new_item' => 'New Contest',
'view_item' => 'View Contest',
'search_items' => 'Search Contests',
'not_found' => 'No contests found',
'not_found_in_trash' => 'No contests found in trash.',
'parent_item_colon' => '',
'menu_name' => 'Contests'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_icon' => 'dashicons-tickets',
'menu_position' => null,
'supports' => array('title','editor'),
'taxonomies' => array( 'contest-details' ),
);
register_post_type( 'contest', $args );
}
add_action( 'init', 'be_register_contest_post_type' );
/* Contest CPT :: Add Taxonomy
**********************************************/
function be_register_contest_details_taxonomy() {
$labels = array(
'name' => 'Contest Details',
'singular_name' => 'Contest Details',
'search_items' => 'Search Contest Details',
'all_items' => 'All Contest Details',
'edit_item' => 'Edit Contest Details',
'update_item' => 'Update Contest Details',
'add_new_item' => 'Add New Contest Details',
'new_item_name' => 'New Contest Details Name',
'menu_name' => 'Contest Details'
);
register_taxonomy( 'contest-details', array('contest'),
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'contest-details' ),
)
);
}
add_action( 'init', 'be_register_contest_details_taxonomy' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment