Skip to Content
PHPCODE
How do I create a custom post type in WordPress?
wordpress code / April 14, 2022
/* Start Testimonials Function*/
function qrs_testimonial_posttype() {
$labels = array(
'name' => _x( 'Testimonials', 'qrs' ),
'singular_name' => _x( 'Testimonial', 'qrs' ),
'add_new' => _x( 'Add New', 'qrs'),
'add_new_item' => __( 'Add New Testimonial' ),
'edit_item' => __( 'Edit Testimonial' ),
'new_item' => __( 'New Testimonial' ),
'all_items' => __( 'All Testimonials' ),
'view_item' => __( 'View Testimonial' ),
'search_items' => __( 'Search Testimonial' ),
'not_found' => __( 'No Testimonial found' ),
'not_found_in_trash' => __( 'No Testimonials found in the Trash' ),
'menu_name' => 'Testimonials'
); 
register_post_type( 'testimonials',
array(
'labels' => $labels,
'public' => true,
'has_archive' => false,
'supports' => array( 'title','editor'),
'rewrite' => array('slug' => 'testimonials'),
'show_in_rest' => true,
)
);
}
add_action( 'init', 'qrs_testimonial_posttype' );
/* End Testimonials Function*/
PHPCODE © 2024