Custom Post Types

Adding a new post type, for when ‘posts’ and ‘pages’ just won’t do.

add_action( 'init', 'my_new_post_types' );
function my_new_post_types() {
    $labels = array(
        'name' => _x('Hotels', 'post type general name'),
        'singular_name' => _x('Hotel', 'post type singular name'),
        'add_new' => _x('Add New', 'hotel'),
        'add_new_item' => __('Add New Hotel'),
        'edit_item' => __('Edit Hotel'),
        'new_item' => __('New Hotel'),
        'view_item' => __('View Hotel'),
        'search_items' => __('Search Hotels'),
        'not_found' =>  __('No hotels found'),
        'not_found_in_trash' => __('No hotels found in Trash'), 
        'parent_item_colon' => '',
        'menu_name' => 'Hotels'    
    );
    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true, 
        'show_in_menu' => true, 
        'query_var' => true,
        'rewrite' => true,
        'capability_type' => 'post',
        'has_archive' => true, 
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','author','thumbnail','excerpt','comments')
    ); 
    register_post_type('hotel',$args);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: