WordPress give a lot of functionality to register a custom post type here is example of code:
<?php
function faq_post_type() {
$labels = array(
'name' => 'FAQ' ,
'singular_name' =>'FAQ',
'menu_name' =>'FAQ',
);
$args = array(
'label' => 'FAQ',
'labels' => $labels,
'supports' => array( ),
'hierarchical' => false,
'public' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-edit',
);
register_post_type( 'faq', $args );
register_taxonomy(
'faq_cat', // slug of taxonomy
'faq', // slug of post type
array(
'label' => __( 'Category' ), // Name of category
'rewrite' => array( 'slug' => 'faq_cat' ),
'hierarchical' => true,
)
);
}
add_action( 'init', 'faq_post_type' );
?>
<?php
function faq_post_type() {
$labels = array(
'name' => 'FAQ' ,
'singular_name' =>'FAQ',
'menu_name' =>'FAQ',
);
$args = array(
'label' => 'FAQ',
'labels' => $labels,
'supports' => array( ),
'hierarchical' => false,
'public' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-edit',
);
register_post_type( 'faq', $args );
register_taxonomy(
'faq_cat', // slug of taxonomy
'faq', // slug of post type
array(
'label' => __( 'Category' ), // Name of category
'rewrite' => array( 'slug' => 'faq_cat' ),
'hierarchical' => true,
)
);
}
add_action( 'init', 'faq_post_type' );
?>
No comments:
Post a Comment