Skip to content

Instantly share code, notes, and snippets.

@kaskajp
Created March 17, 2015 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaskajp/d114f24122ba95670bbf to your computer and use it in GitHub Desktop.
Save kaskajp/d114f24122ba95670bbf to your computer and use it in GitHub Desktop.
Custom Post Type as Plugin
<?php
/*
Plugin Name: A Custom Post Type
Plugin URI: http://kaska.jp/
Description: A simple barebones custom post type.
Version: 1.0
Author: Jonas Raneryd
Author URI: http://kaska.jp/
License: MIT
*/
add_action( 'init', 'register_cpt_acpt' );
function register_cpt_acpt() {
$labels = array(
'name' => _x( 'Something', 'acpt' ),
'singular_name' => _x( 'Something', 'acpt' ),
'add_new' => _x( 'Add new', 'acpt' ),
'add_new_item' => _x( 'Add new something', 'acpt' ),
'edit_item' => _x( 'Edit something', 'acpt' ),
'new_item' => _x( 'New something', 'acpt' ),
'view_item' => _x( 'View something', 'acpt' ),
'search_items' => _x( 'Search something', 'acpt' ),
'not_found' => _x( 'No somethings found', 'acpt' ),
'not_found_in_trash' => _x( 'No somethings found in the trash', 'acpt' ),
'parent_item_colon' => _x( 'Parent Something:', 'acpt' ),
'menu_name' => _x( 'Somethings', 'acpt' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( 'acpt', $args );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment