Create a custom post type in wordpress
Create a custom post type in WordPress.
First of all, you have to use the default WordPress hooks. add_action.
add_action( 'init', 'my_custom_post_yblog' );
function my_custom_post_yblog(){
$labels = array(
'name' => _x( 'yblog', 'post type general name' ),
'singular_name' => _x( 'yblog', 'post type singular name' ),
'add_new' => _x( 'Add New', 'yblog' ),
'add_new_item' => __( 'Add New yblog' ),
'edit_item' => __( 'Edit yblog' ),
'new_item' => __( 'New yblog' ),
'all_items' => __( 'All yblog' ),
'view_item' => __( 'View yblog' ),
'search_items' => __( 'Search yblog' ),
'not_found' => __( 'No products found' ),
'not_found_in_trash' => __( 'No products found in the Trash' ),
'parent_item_colon' => ’,
'menu_name' => 'yblog'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our yblog and yblog specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), // support
'has_archive' => true,
);
register_post_type( 'yblog', $args );
}
// If you want to create a category in your custom post type.
function my_taxonomies_yblog() {
$labels = array(
'name' => _x( 'yblog Categories', 'taxonomy general name' ),
'singular_name' => _x( 'yblog Category', 'taxonomy singular name' ),
'search_items' => __( 'yblog yblog Categories' ),
'all_items' => __( 'All yblog Categories' ),
'parent_item' => __( 'Parent yblog Category' ),
'parent_item_colon' => __( 'Parent yblog Category:' ),
'edit_item' => __( 'Edit yblog Category' ),
'update_item' => __( 'Update yblog Category' ),
'add_new_item' => __( 'Add New yblog Category' ),
'new_item_name' => __( 'New yblog Category' ),
'menu_name' => __( 'yblog Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'yblog_category', 'yblog', $args );
}
add_action( 'init', 'my_taxonomies_yblog', 0 );
First of all, you have to use the default WordPress hooks. add_action.
add_action( 'init', 'my_custom_post_yblog' );
function my_custom_post_yblog(){
$labels = array(
'name' => _x( 'yblog', 'post type general name' ),
'singular_name' => _x( 'yblog', 'post type singular name' ),
'add_new' => _x( 'Add New', 'yblog' ),
'add_new_item' => __( 'Add New yblog' ),
'edit_item' => __( 'Edit yblog' ),
'new_item' => __( 'New yblog' ),
'all_items' => __( 'All yblog' ),
'view_item' => __( 'View yblog' ),
'search_items' => __( 'Search yblog' ),
'not_found' => __( 'No products found' ),
'not_found_in_trash' => __( 'No products found in the Trash' ),
'parent_item_colon' => ’,
'menu_name' => 'yblog'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our yblog and yblog specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ), // support
'has_archive' => true,
);
register_post_type( 'yblog', $args );
}
// If you want to create a category in your custom post type.
function my_taxonomies_yblog() {
$labels = array(
'name' => _x( 'yblog Categories', 'taxonomy general name' ),
'singular_name' => _x( 'yblog Category', 'taxonomy singular name' ),
'search_items' => __( 'yblog yblog Categories' ),
'all_items' => __( 'All yblog Categories' ),
'parent_item' => __( 'Parent yblog Category' ),
'parent_item_colon' => __( 'Parent yblog Category:' ),
'edit_item' => __( 'Edit yblog Category' ),
'update_item' => __( 'Update yblog Category' ),
'add_new_item' => __( 'Add New yblog Category' ),
'new_item_name' => __( 'New yblog Category' ),
'menu_name' => __( 'yblog Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'yblog_category', 'yblog', $args );
}
add_action( 'init', 'my_taxonomies_yblog', 0 );
Comments
Post a Comment