25% off ProSNIPC25OFF

Register a Testimonials Post Type

Registers a Testimonials custom post type with a public archive, admin UI, and support for title, editor, and thumbnail.

PHPby SnipCraft
php
<?php
add_action( 'init', 'scseed_register_testimonials_cpt' );
if ( ! function_exists( 'scseed_register_testimonials_cpt' ) ) {
    function scseed_register_testimonials_cpt() {
        $labels = array(
            'name'               => 'Testimonials',
            'singular_name'      => 'Testimonial',
            'add_new_item'       => 'Add New Testimonial',
            'edit_item'          => 'Edit Testimonial',
            'new_item'           => 'New Testimonial',
            'view_item'          => 'View Testimonial',
            'search_items'       => 'Search Testimonials',
            'not_found'          => 'No testimonials found',
            'not_found_in_trash' => 'No testimonials found in trash',
            'menu_name'          => 'Testimonials',
        );
        register_post_type( 'testimonial', array(
            'labels'       => $labels,
            'public'       => true,
            'has_archive'  => true,
            'rewrite'      => array( 'slug' => 'testimonials' ),
            'supports'     => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
            'show_in_rest' => true,
            'menu_icon'    => 'dashicons-format-quote',
        ) );
    }
}
#content#cpt#register-post-type#testimonials