Skip to content

Instantly share code, notes, and snippets.

@robincornett robincornett/great-dishes.php Secret
Last active Aug 29, 2015

Embed
What would you like to do?
Great Dishes Custom Post Type
<?php
/**
* Great Dishes is a dead simple plugin to make a menu for a restaurant.
*
* @package Great Dishes
* @author Robin Cornett <hello@robincornett.com>
* @copyright 2015 Robin Cornett
* @license GPL-2.0+
* @link http://robincornett.com
*
* @wordpress-plugin
* Plugin Name: Great Dishes
* Plugin URI: https://github.com/robincornett/
* Description: Great Dishes is a dead simple plugin to make a menu for a restaurant.
* Version: 1.0.0
* Author: Robin Cornett
* Author URI: http://robincornett.com
* Text Domain: great-dishes
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Domain Path: /languages
*/
// Hook into the 'init' action
add_action( 'init', 'great_dishes_register_post_type' );
// Register Custom Post Type
function great_dishes_register_post_type() {
$labels = array(
'name' => _x( 'Great Dishes', 'Post Type General Name', 'great-dishes' ),
'singular_name' => _x( 'Dish', 'Post Type Singular Name', 'great-dishes' ),
'menu_name' => __( 'Great Dishes', 'great-dishes' ),
'parent_item_colon' => __( 'Parent Dish:', 'great-dishes' ),
'all_items' => __( 'All Dishes', 'great-dishes' ),
'view_item' => __( 'View Dish', 'great-dishes' ),
'add_new_item' => __( 'Add New Dish', 'great-dishes' ),
'add_new' => __( 'Add New', 'great-dishes' ),
'edit_item' => __( 'Edit Dish', 'great-dishes' ),
'update_item' => __( 'Update Dish', 'great-dishes' ),
'search_items' => __( 'Search Item', 'great-dishes' ),
'not_found' => __( 'Not found', 'great-dishes' ),
'not_found_in_trash' => __( 'Not found in Trash', 'great-dishes' ),
);
$rewrite = array(
'slug' => 'menu',
'with_front' => true,
'pages' => true,
'feeds' => false,
);
$args = array(
'label' => __( 'Great Dishes', 'great-dishes' ),
'description' => __( 'Great Dishes', 'great-dishes' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes', 'genesis-cpt-archives-settings' ),
'taxonomies' => array( 'course' ),
'hierarchical' => true,
'menu_icon' => 'dashicons-heart',
'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' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'great_dish', $args );
}
// Hook into the 'init' action
add_action( 'init', 'great_dishes_register_taxonomy' );
// Register Custom Taxonomy
function great_dishes_register_taxonomy() {
$labels = array(
'name' => _x( 'Courses', 'Taxonomy General Name', 'great-dishes' ),
'singular_name' => _x( 'Course', 'Taxonomy Singular Name', 'great-dishes' ),
'menu_name' => __( 'Courses', 'great-dishes' ),
'all_items' => __( 'All Courses', 'great-dishes' ),
'parent_item' => __( 'Parent Course', 'great-dishes' ),
'parent_item_colon' => __( 'Parent Course:', 'great-dishes' ),
'new_item_name' => __( 'New Course', 'great-dishes' ),
'add_new_item' => __( 'Add New Course', 'great-dishes' ),
'edit_item' => __( 'Edit Course', 'great-dishes' ),
'update_item' => __( 'Update Course', 'great-dishes' ),
'separate_items_with_commas' => __( 'Separate courses with commas', 'great-dishes' ),
'search_items' => __( 'Search Courses', 'great-dishes' ),
'add_or_remove_items' => __( 'Add or remove courses', 'great-dishes' ),
'choose_from_most_used' => __( 'Choose from the most used courses', 'great-dishes' ),
'not_found' => __( 'Not Found', 'great-dishes' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
);
register_taxonomy( 'course', array( 'great_dish' ), $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.