Wednesday, December 10, 2014

Creating custom post type in wordpress



You can create custom post type in wordpress. For this you can use function.php file that already  exist in your theme folder or you can write it on your theme default plugin file or you can create a new plugin to create custom post type.The function to create a custom post type is following -


function create_custom_posttype() {
    register_post_type( 'tutorial',
    // CPT Options
        array(
            'labels' => array(
                'name' => __( 'Tutorial' ),
                'singular_name' => __( 'Tutorial' )
            ),
            'public' => true,
            'has_archive' => true,
   'taxonomies' => array('category','post_tag'),//add category and tag
            'rewrite' => array('slug' => 'tutorial'),
        )
    );
}

add_action( 'init', 'create_custom_posttype' );

Here we create a custom post type named Tutorial.  

1 comments :

 

Copyright @ 2014 Tech Tutorial .