Last active
March 8, 2018 07:01
-
-
Save rachelmccollin/9732e7abe648b5f8c436 to your computer and use it in GitHub Desktop.
WPMU DEV snippets
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
<?php | |
/*Plugin Name: Create Product Post Type | |
Description: This plugin registers the 'product' post type. | |
Version: 1.0 | |
License: GPLv2 | |
*/ | |
// register custom post type to work with | |
function wpmudev_create_post_type() { | |
// set up labels | |
$labels = array( | |
'name' => 'Products', | |
'singular_name' => 'Product', | |
'add_new' => 'Add New Product', | |
'add_new_item' => 'Add New Product', | |
'edit_item' => 'Edit Product', | |
'new_item' => 'New Product', | |
'all_items' => 'All Products', | |
'view_item' => 'View Product', | |
'search_items' => 'Search Products', | |
'not_found' => 'No Products Found', | |
'not_found_in_trash' => 'No Products found in Trash', | |
'parent_item_colon' => '', | |
'menu_name' => 'Products', | |
); | |
//register post type | |
register_post_type( 'product', array( | |
'labels' => $labels, | |
'has_archive' => true, | |
'public' => true, | |
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail','page-attributes' ), | |
'taxonomies' => array( 'post_tag', 'category' ), | |
'exclude_from_search' => false, | |
'capability_type' => 'post', | |
'rewrite' => array( 'slug' => 'products' ), | |
) | |
); | |
} | |
add_action( 'init', 'wpmudev_create_post_type' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment