Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1.  
  2.  
  3.  
  4. function Testimonial_Shortcode_loop_shortcode() {
  5.     ob_start();
  6.     $args = array(
  7.         'post_type' => 'testimonials',
  8.         'post_status' => 'publish',
  9.     );
  10.     $my_query = null;
  11.     $my_query = new WP_query($args);
  12.     if ($my_query->have_posts()):
  13.         echo ' <ul class="slickslide">';
  14.          while ($my_query->have_posts()) : $my_query->the_post(); ?>
  15.                      
  16.         <li><?php echo  the_content(); ?></li>
  17.        
  18.   <?php
  19.          endwhile;
  20.         wp_reset_postdata();
  21.     else :
  22.         _e('Sorry, no posts matched your criteria.');
  23.     endif; ?>
  24.     </ul>
  25.     <div class="slick-thumbs">
  26.         <ul>
  27.          <?php       $args = array(
  28.         'post_type' => 'testimonials',
  29.         'post_status' => 'publish',
  30.     );
  31.     $my_query = null;
  32.     $my_query = new WP_query($args);
  33.     if ($my_query->have_posts()): ?>
  34.    
  35.     <?php  while ($my_query->have_posts()) : $my_query->the_post(); ?>
  36.  
  37.              <li>
  38.                 <?php
  39.                             if ( has_post_thumbnail() ) {
  40.                                     the_post_thumbnail('testimonial-thumb-size');
  41.                                 }
  42.                                 else {
  43.                                     $string = get_the_title();
  44.                                     echo '<span class="fake-testimonial-name">'.$string[0].'</span>';
  45.                                 } ?>
  46.             </li>
  47.            
  48.             <?php
  49.          endwhile;
  50.         wp_reset_postdata();
  51.     else :
  52.         _e('Sorry, no posts matched your criteria.');
  53.     endif; ?>
  54.         </ul>
  55.  
  56.            <?php
  57.     return ob_get_clean();
  58.    
  59. }
  60. add_shortcode('cleere-testimonials', 'Testimonial_Shortcode_loop_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement