Skip to content

Instantly share code, notes, and snippets.

@joecue
Created July 17, 2015 18:38
Show Gist options
  • Save joecue/d0a5e37f3d1bbe17ae1f to your computer and use it in GitHub Desktop.
Save joecue/d0a5e37f3d1bbe17ae1f to your computer and use it in GitHub Desktop.
Recipe Custom Post Type Plugin
<?php
/*
Plugin Name: Site Plugin for WordCamp Columbus 2015
Description: Site specific code changes for example.com
*/
/* Start Adding Functions Below this Line */
// Hook into the 'init' action
add_action( 'init', 'demo_post_types', 0 );
function demo_post_types() {
$labels = array(
'name' => _x( 'Recipes', 'My Recipes', 'text_domain' ),
'singular_name' => _x( 'Recipe', 'Recipe', 'text_domain' ),
'menu_name' => __( 'My Recipes', 'text_domain' ),
'name_admin_bar' => __( 'My Recipes', 'text_domain' ),
'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
'all_items' => __( 'All Recipes', 'text_domain' ),
'add_new_item' => __( 'Add New Recipe', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'new_item' => __( 'New Recipe', 'text_domain' ),
'edit_item' => __( 'Edit Recipe', 'text_domain' ),
'update_item' => __( 'Update Recipe', 'text_domain' ),
'view_item' => __( 'View Recipe', 'text_domain' ),
'search_items' => __( 'Search Recipes', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'recipe_post_type', 'text_domain' ),
'description' => __( 'Recipes', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'recipe_post_type', $args );
$labels = array(
'name' => _x( 'Menus', 'Menus', 'text_domain' ),
'singular_name' => _x( 'Menu', 'Menu', 'text_domain' ),
'menu_name' => __( 'My Menus', 'text_domain' ),
'name_admin_bar' => __( 'My Menus', 'text_domain' ),
'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
'all_items' => __( 'All Recipes', 'text_domain' ),
'add_new_item' => __( 'Add New Recipe', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'new_item' => __( 'New Recipe', 'text_domain' ),
'edit_item' => __( 'Edit Recipe', 'text_domain' ),
'update_item' => __( 'Update Recipe', 'text_domain' ),
'view_item' => __( 'View Recipe', 'text_domain' ),
'search_items' => __( 'Search Recipes', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$args = array(
'label' => __( 'recipe_post_type', 'text_domain' ),
'description' => __( 'Recipes', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
);
register_post_type( 'menu_post_type', $args );
}
/* Stop Adding Functions Below this Line */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment