Guest User

Untitled

a guest
Sep 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. add_shortcode('testimonials', 'testimonial_query');
  2. function testimonial_query($atts, $content){
  3. extract(shortcode_atts(array( // a few default values
  4.  
  5. 'id' => null,
  6. 'posts_per_page' => '1',
  7. 'caller_get_posts' => 1)
  8. , $atts));
  9. $args = array(
  10. 'post_type' => 'testimonial',
  11. 'numberposts' => -1
  12. );
  13. global $post;
  14. $posts = new WP_Query($args);
  15. $output = '';
  16. if ($posts->have_posts( $attributes['id']))
  17. while ($posts->have_posts( $attributes['id'])):
  18. $posts->the_post();
  19. $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' );
  20. $out = '<div class="testimonial-img">
  21. <img src="'.$url.'" />
  22. </div>
  23. <div class="testimonial_content">
  24. <img src="'.get_field('logo').'" alt="icon">
  25. <p class="testimonial_desc">'.get_the_content().'</p>
  26. <div class="author-details">
  27. <img src="'.get_field('author_image').'" alt="image">
  28. <p>'.get_field('author_name').' <span>'.get_field('author_designation').'</span></p>
  29. </div>';
  30. // add here more...
  31. $out .='</div>';
  32. endwhile;
  33. else
  34. return; // no posts found
  35.  
  36. wp_reset_query();
  37. return html_entity_decode($out);
  38. }
Add Comment
Please, Sign In to add comment