Last active
August 29, 2015 14:21
-
-
Save pingram3541/08454eed287526fb5241 to your computer and use it in GitHub Desktop.
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
/* --------------------------------------------------------------------------- | |
* Add Specials custom post type | |
* --------------------------------------------------------------------------- */ | |
function create_specials_cpt(){ | |
register_post_type( 'specials', | |
// CPT Options | |
array( | |
'labels' => array( | |
'name' => __( 'Specials' ), | |
'singular_name' => __( 'Special' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'rewrite' => array('slug' => 'specials'), | |
) | |
); | |
} | |
add_action( 'init', 'create_specials_cpt' ); | |
/* --------------------------------------------------------------------------- | |
* Define Specials custom post type | |
* --------------------------------------------------------------------------- */ | |
function define_specials_cpt() { | |
// Set UI labels for Custom Post Type | |
$labels = array( | |
'name' => _x( 'Specials', 'Post Type General Name', 'mfn-opts' ), | |
'singular_name' => _x( 'Special', 'Post Type Singular Name', 'mfn-opts' ), | |
'menu_name' => __( 'Specials', 'mfn-opts' ), | |
'parent_item_colon' => __( 'Parent Special', 'mfn-opts' ), | |
'all_items' => __( 'All Specials', 'mfn-opts' ), | |
'view_item' => __( 'View Special', 'mfn-opts' ), | |
'add_new_item' => __( 'Add New Special', 'mfn-opts' ), | |
'add_new' => __( 'Add New', 'mfn-opts' ), | |
'edit_item' => __( 'Edit Special', 'mfn-opts' ), | |
'update_item' => __( 'Update Special', 'mfn-opts' ), | |
'search_items' => __( 'Search Specials', 'mfn-opts' ), | |
'not_found' => __( 'Not Found', 'mfn-opts' ), | |
'not_found_in_trash' => __( 'Not found in Trash', 'mfn-opts' ), | |
); | |
// Set other options for Custom Post Type | |
$args = array( | |
'label' => __( 'specials', 'mfn-opts' ), | |
'description' => __( 'Current coupons and specials', 'mfn-opts' ), | |
'labels' => $labels, | |
// Features this CPT supports in Post Editor | |
//'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ), | |
'supports' => array( 'title', 'editor', 'custom-fields', ), | |
// You can associate this CPT with a taxonomy or custom taxonomy. | |
//'taxonomies' => array( 'locations' ), | |
'taxonomies' => array('category'), | |
/* A hierarchical CPT is like Pages and can have | |
* Parent and child items. A non-hierarchical CPT | |
* is like Posts. | |
*/ | |
'hierarchical' => false, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_nav_menus' => true, | |
'show_in_admin_bar' => true, | |
'menu_position' => 5, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => true, | |
'publicly_queryable' => true, | |
//'rewrite' => array('slug' => 'special','with_front' => true), | |
'capability_type' => 'post', | |
); | |
// Registering your Custom Post Type | |
register_post_type( 'specials', $args ); | |
} | |
add_action( 'init', 'define_specials_cpt', 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment