Wordpress custom post type

Sometimes you will need some more functionalities than CMS has in default configuration. Wordpress gives you simple way to create your own content type based on post/page content type. How to do it?

Add this code to your functions.php file and… voila!

function create_post_type() {
    $labels = array(
        'name'               => _x( '<Name of your post types>', 'post type general name' ),
        'singular_name'      => _x( '<Name of singular element>', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'book' ),
        'add_new_item'       => __( 'Add New Element' ),
        'edit_item'          => __( 'Edit Element' ),
        'new_item'           => __( 'New Element' ),
        'all_items'          => __( 'All Elements' ),
        'view_item'          => __( 'View Element' ),
        'search_items'       => __( 'Search Elements' ),
        'not_found'          => __( 'No Element found' ),
        'not_found_in_trash' => __( 'No Element found in the Trash' ),
        'parent_item_colon'  => '',
        'menu_name'          => 'Element'
    );

    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds our products and product specific data',
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'type', 'post-formats' ), // which features custom post type should provide 
        'has_archive'   => true,
    );

    register_post_type( 'element', $args );
}

function my_taxonomies_elements() {
    $labels = array(
        'name'              => _x( 'Elements Categories', 'taxonomy general name' ),
        'singular_name'     => _x( 'Element Category', 'taxonomy singular name' ),
        'search_items'      => __( 'Search Element Categories' ),
        'all_items'         => __( 'All Element Categories' ),
        'parent_item'       => __( 'Parent Element Category' ),
        'parent_item_colon' => __( 'Parent Element Category:' ),
        'edit_item'         => __( 'Edit Element Category' ),
        'update_item'       => __( 'Update Element Category' ),
        'add_new_item'      => __( 'Add New Element Category' ),
        'new_item_name'     => __( 'New Element Category' ),
        'menu_name'         => __( 'Element Categories' ),
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
    );

    register_taxonomy( 'element_category', '  portfolio', $args );
}

add_action( 'init', 'create_post_type' );
add_action( 'init', 'my_taxonomies_elements',0);