- $orderBy = get_field('testimonial_order');
- global $post;
- $arguments = [
- 'post_type' => 'testimonial',
- 'posts_per_page' => -1,
- 'order' => $orderBy,
- ];
- if ( $categories = get_field('testimonial_category') ) {
- $arguments['tax_query'] = [
- [
- 'taxonomy' => 'testimonial_tax',
- 'field' => 'term_id',
- 'terms' => $categories,
- ]
- ];
- }
- if ( $orderby = get_field('testimonial_sort') ) {
- $arguments['orderby'] = $orderby;
- }
- $testimonial_query = new WP_Query( $arguments );
- if ( $testimonial_query->have_posts() ) {
- $className = 'custom-testimonial-block testimonial-block';
- if( !empty($block['className']) ) {
- $className .= ' ' . $block['className'];
- }
- $block_id = 'testimonials_'.$block['id'];
- echo "<div class='$className'>";
- echo "<div class='swiper-container' id='$block_id'>";
- echo "<div class='swiper-wrapper'>";
- $index = 0;
- while ( $testimonial_query->have_posts() ) {
- $testimonial_query->the_post();
- $overline = get_field('testimonial_overline', $post->ID);
- $content = get_field('testimonial_content', $post->ID);
- $image = get_field('testimonial_image', $post->ID);
- $company = get_field('testimonial_company_client', $post->ID);
- $name = get_field('testimonial_name', $post->ID);
- $index++;
- $elementClass = 'testimonial-element';
- if ($index % 2 === 0) {
- $elementClass .= ' even';
- } else {
- $elementClass .= ' odd';
- }
- echo "<div class='swiper-slide'>";
- $__ = '';
- if(!empty($image)) {
- $__ .= "<div class='image-container'>";
- $__ .= get_img_set($image, 'relative', 25, ['type'=>'img']); //the function get_img_set is not implemented in this project, so you have to use the regular function from WP which you allready used with the image slider
- $__ .= "</div>";
- }
- $__ .= "<div class='content-container'>";
- $__ .= "<div class='testimonial-title'>$overline</div>";
- $__ .= "<div class='testimonial-text'>$content</div>";
- $__ .= "<div class='testimonial-user'><span>$company</span>, $name</div>";
- $__ .= "</div>";
- echo "<div class='$elementClass'>$__</div>";
- echo "</div>";
- }
- echo "</div>";
- echo "</div>";
- echo "<div class='slider-prev slider-button' id='$block_id-prev'><span class='fal fa-angle-left'></span></div>";
- echo "<div class='slider-pagination' id='$block_id-pagination'></div>";
- echo "<div class='slider-next slider-button' id='$block_id-next'><span class='fal fa-angle-right'></span></div>";
- }
- <?php
- echo "</div>";
Recent Pastes