Preview:
function create_product() {

$labels = array(
    'name' => _x( 'Product', 'Post Type General Name'),
    'singular_name' => _x( 'Product', 'Post Type Singular Name'),
    'menu_n ame' => _x( 'Products', 'Admin Menu text'),
    'name_admin_bar' => _x( 'Products', 'Add New on Toolbar'),
    'archives' => __( 'Products Archives'),
    'attributes' => __( 'Products Attributes'),
    'parent_item_colon' => __( 'Parent Products:'),
    'all_items' => __( 'All Products'),
    'add_new_item' => __( 'Add New Products'),
    'add_new' => __( 'Add New'),
    'new_item' => __( 'New Products'),
    'edit_item' => __( 'Edit Products'),
    'update_item' => __( 'Update Products'),
    'view_item' => __( 'View Products'),
    'view_items' => __( 'View Products'),
    'search_items' => __( 'Search Products'),
    'not_found' => __( 'Not found'),
    'not_found_in_trash' => __( 'Not found in Trash'),
    'featured_image' => __( 'Featured Image'),
    'set_featured_image' => __( 'Set featured image'),
    'remove_featured_image' => __( 'Remove featured image'),
    'use_featured_image' => __( 'Use as featured image'),
    'insert_into_item' => __( 'Insert into Products'),
    'uploaded_to_this_item' => __( 'Uploaded to this Products'),
    'items_list' => __( 'Products list'),
    'items_list_navigation' => __( 'Products list navigation'),
    'filter_items_list' => __( 'Filter Products list'),
);
$args = array(
    'label' => __( 'Products'),
    'description' => __( ''),
    'labels' => $labels,
    'menu_icon' => 'dashicons-admin-page',
    'supports' => array('title', 'editor', 'excerpt', 'thumbnail','page-attributes'),
    'taxonomies' => array(),
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'menu_position' => 5,
    'show_in_admin_bar' => true,
    'show_in_nav_menus' => true,
    'can_export' => true,
    'has_archive' => true,
    'hierarchical' => false,
    'exclude_from_search' => false,
    'show_in_rest' => true,
    'publicly_queryable' => true,
    'capability_type' => 'post',
);
register_post_type( 'products', $args );

}
add_action( 'init', 'create_product');
function product_loop()
{
ob_start();
wp_reset_postdata();


$arg = array(
    'post_type' => 'products',
    'posts_per_page' => -1,
);

$themeslider = new WP_Query($arg);
?>

<div class="product_slider">
    <?php if ($themeslider->have_posts()) : ?>
        <?php while ($themeslider->have_posts()) : ?>
            <?php $themeslider->the_post();
            $url = wp_get_attachment_url(get_post_thumbnail_id($themeslider->ID));
            ?>
                <div class="cbd_main">
                    <div class="cbd_img">
                        <?php $url = wp_get_attachment_url(get_post_thumbnail_id($themeslider->ID)); ?>
                        <img src="<?php echo $url; ?>">
                    </div>
                    <div class="cbd_inner">
                        <h1><?php the_title(); ?></h1>
                        <div class="home_content"><?php echo wp_trim_words( get_the_content(), 40, '' ); ?></div>
                    </div>
                </div>

        <?php endwhile; ?>
    <?php endif; ?>
</div>
<?php
wp_reset_postdata();
return '' . ob_get_clean();
}
add_shortcode( 'product_code', 'product_loop' );


//////////////////////jss

jQuery('.product_slider').slick({
  dots: false,
  infinite: true,
	autoplay: false,
	centerPadding:'100px',
	arrows: false,
  speed: 300,
	centerMode: true,
 slidesToShow: 3,
 slidesToScroll: 1,
 responsive: [
   {
     breakpoint: 1024,
     settings: {
       slidesToShow: 3,
       slidesToScroll: 1,
       infinite: false,
       dots: false
     }
   },
   {
     breakpoint: 600,
     settings: {
       slidesToShow: 3,
       slidesToScroll: 1
     }
   },
   {
     breakpoint: 480,
     settings: {
       slidesToShow: 1,
       slidesToScroll: 1
     }
   }
 ]
});

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter