Last active
August 29, 2015 14:09
-
-
Save steppohub/be52d1df827589a215b7 to your computer and use it in GitHub Desktop.
Add new custom post type
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
function my_custom_post_product() { | |
$labels = array( | |
'name' => _x( 'Products', 'post type general name' ), | |
'singular_name' => _x( 'Product', 'post type singular name' ), | |
'add_new' => _x( 'Add New', 'book' ), | |
'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 the Trash' ), | |
'parent_item_colon' => '', | |
'menu_name' => 'Products' | |
); | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Holds our products and product specific data', | |
'public' => true, | |
'menu_position' => 5, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), | |
'has_archive' => true, | |
); | |
register_post_type( 'product', $args ); | |
} | |
add_action( 'init', 'my_custom_post_product' ); | |
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
function my_custom_post_news() { | |
$labels = array( | |
'name' => _x( 'News', 'post type general name' ), | |
'singular_name' => _x( 'News', 'post type singular name' ), | |
'add_new' => _x( 'Add New', 'news' ), | |
'add_new_item' => __( 'Add New News' ), | |
'edit_item' => __( 'Edit News' ), | |
'new_item' => __( 'New News' ), | |
'all_items' => __( 'All News' ), | |
'view_item' => __( 'View News' ), | |
'search_items' => __( 'Search News' ), | |
'not_found' => __( 'No news found' ), | |
'not_found_in_trash' => __( 'No news found in the Trash' ), | |
'parent_item_colon' => '', | |
'menu_name' => 'News' | |
); | |
$args = array( | |
'labels' => $labels, | |
'description' => 'Our latest news', | |
'public' => true, | |
'menu_position' => 5, | |
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), | |
'has_archive' => true, | |
); | |
register_post_type( 'news', $args ); | |
} | |
add_action( 'init', 'my_custom_post_news' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment