Skip to content

Instantly share code, notes, and snippets.

@kirandash
Created April 19, 2017 05:44
Show Gist options
  • Select an option

  • Save kirandash/ab5b7dc247f3958471044f1969b6903c to your computer and use it in GitHub Desktop.

Select an option

Save kirandash/ab5b7dc247f3958471044f1969b6903c to your computer and use it in GitHub Desktop.
Register Custom Post type
<?php
/*
Plugin Name: Demo
Plugin URI: demo.com
Description: Demo Features
Version: 1.0.0
Author: WordPress.org
Author URI: demo.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: Demo
Domain Path: /languages
*/
$labels = array(
'name' => _x( 'events', 'post type general name', 'tzmotorsport' ),
'singular_name' => _x( 'event', 'post type singular name', 'tzmotorsport' ),
'menu_name' => _x( 'events', 'admin menu', 'tzmotorsport' ),
'name_admin_bar' => _x( 'event', 'add new on admin bar', 'tzmotorsport' ),
'add_new' => _x( 'Add New', 'event', 'tzmotorsport' ),
'add_new_item' => __( 'Add New event', 'tzmotorsport' ),
'new_item' => __( 'New event', 'tzmotorsport' ),
'edit_item' => __( 'Edit event', 'tzmotorsport' ),
'view_item' => __( 'View event', 'tzmotorsport' ),
'all_items' => __( 'All events', 'tzmotorsport' ),
'search_items' => __( 'Search events', 'tzmotorsport' ),
'parent_item_colon' => __( 'Parent events:', 'tzmotorsport' ),
'not_found' => __( 'No events found.', 'tzmotorsport' ),
'not_found_in_trash' => __( 'No events found in Trash.', 'tzmotorsport' )
);
$args = array(
'labels' => $labels,
'description' => __( 'events for TZ Motorsport.', 'tzmotorsport' ),
'menu_icon' => 'dashicons-universal-access-alt',
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'events' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' )
);
register_post_type( 'events', $args );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment