function testimonialLoop() { ob_start(); $args = array( 'post_type' => 'our-testimonials', 'posts_per_page' => -1 ); $result = new WP_Query($args); ?> <div class="row"> <div class="col-md-10"> <div class="slider-for"> <?php if ($result->have_posts()) : ?> <?php while ($result->have_posts()) : $result->the_post(); ?> <div class="testimonialsSingle"> <div class="testimonialsContent"> <div class="testimonialsContentInner"> <div class="ContentInner"> <div class="serDesc"><?php echo wp_trim_words(get_the_content(), 20, '...'); ?></div> <div class="rating"> <span class="star <?php the_field('rating'); ?>"></span> </div> <div class="testimonialTitle"> <span><strong><?php the_title(); ?></strong></span> / <span><?php the_field('designation'); ?></span> </div> </div> </div> <?php the_post_thumbnail('full'); ?> </div> </div> <?php endwhile; ?> <?php endif; ?> </div> </div> <div class="col-md-2"> <div class="slider-nav"> <?php if ($result->have_posts()) : ?> <?php while ($result->have_posts()) : $result->the_post(); ?> <div class="testimonialsImg"> <?php the_post_thumbnail('full'); ?> </div> <?php endwhile; ?> <?php endif; ?> </div> </div> </div> <?php wp_reset_postdata(); return ob_get_clean(); } add_shortcode('testimonial-code', 'testimonialLoop');
Preview:
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