Skip to content

Instantly share code, notes, and snippets.

@FernE97
Created March 9, 2012 05:08
Show Gist options
  • Save FernE97/2005147 to your computer and use it in GitHub Desktop.
Save FernE97/2005147 to your computer and use it in GitHub Desktop.
PHP: WordPress Custom Post Type
<?php
function register_cpt_slides() {
$post_type = 'slides';
$labels = array(
'name' => _x( 'Slides', $post_type ),
'singular_name' => _x( 'Slide', $post_type ),
'add_new' => _x( 'Add New', $post_type ),
'add_new_item' => _x( 'Add New Slide', $post_type ),
'edit_item' => _x( 'Edit Slide', $post_type ),
'new_item' => _x( 'New Slide', $post_type ),
'view_item' => _x( 'View Slide', $post_type ),
'search_items' => _x( 'Search Slides', $post_type ),
'not_found' => _x( 'No resort specials found', $post_type ),
'not_found_in_trash' => _x( 'No resort specials found in Trash', $post_type ),
'parent_item_colon' => _x( 'Parent Slide:', $post_type ),
'menu_name' => _x( 'Slides', $post_type ),
);
$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions' ),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);
register_post_type( $post_type, $args );
}
add_action( 'init', 'register_cpt_slides' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment