Adding star ratings to testimonials slider

So I've built a testimonials post type into my WordPress theme added it to a slider on the homepage but I'm getting confused when it comes to adding the rating given by the customers can anyone point me in the right direction im not interested in using a plugin

function custom_testimonials() {

    $labels = array(
        'name' = __( 'testimonials' ),
        'singular_name' = __( 'Testimonials' ),
        'all_items'           = __( 'All Testimonials' ),
        'view_item'           = __( 'View Testimonial' ),
        'add_new_item'        = __( 'Add New Testimonial' ),
        'add_new'             = __( 'Add New Testimonial' ),
        'edit_item'           = __( 'Edit Testimonial' ),
        'update_item'         = __( 'Update Testimonial' ),
        'search_items'        = __( 'Search Testimonials' ),
        'search_items' = __('Testimonials')
    );

    $args = array(
        'labels' = $labels,
        'description' = 'Add New Testimonial contents',
        'menu_position' = 28,
        'public' = true,
        'has_archive' = true,
        'map_meta_cap' = true,
        'capability_type' = 'post',
        'hierarchical' = true,
        'rewrite' = array('slug' = false),
        'menu_icon'='dashicons-smiley',
        'supports' = array(
            'title',
            'editor'
        ),
    );
    register_post_type( 'testimonials', $args);

}

Topic theme-development custom-post-types Wordpress

Category Web


You need a way of adding more meta to you cpt so you require an input method dependent on your build you have a few ways of doing this like advanced custom fields or cmb2, acf or cmb2 would be the easiest options but you say you dont want to use any plugins so you would need to create a custom meta box

https://developer.wordpress.org/reference/functions/add_meta_box/

then call this field into your slider loop

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.