how to create custom post type in wordpress with or without categories
/******slider in dashboard***********/
function my_custom_sliders_posttype(){
$args = array(
'labels'=> array( 'name'=>'sliders',
'singular_name'=> 'slider',
'menu_name'=>'sliders',
'name_admin_bar'=> 'sliders',
'all_items' =>'View all sliders',
'add_new'=> 'Add New sliders' ),
'description' =>"This post type is for sliders",
'public' => true,
'exclude_from_search'=>false,
'publicly_queryable'=> true,
'show_ui' => true,
'show_in_menu'=> true,
'show_in_admin_bar'=> true,
'menu_position'=>6,
'capability_type'=> 'page',
'supports'=> array( 'title', 'editor', 'author', 'thumbnail', 'excerpt',
),
'query_var'=>true,
);
register_post_type( "sliders", $args );
}
add_action("init","my_custom_sliders_posttype");
/********************/
IF NEED sub-categories add this code after
add_action("init","my_custom_sliders_posttype");
/**********categories in custom post type ***********/
register_post_type('blog', $portfolio_args);
$categories_labels = array(
'label' => 'blog Category',
'hierarchical' => true,
'query_var' => true
);
/*********./categories in custom post type ***********/
Comments
Post a Comment