Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode('testimonials', 'testimonial_query');
- function testimonial_query($atts, $content){
- extract(shortcode_atts(array( // a few default values
- 'id' => null,
- 'posts_per_page' => '1',
- 'caller_get_posts' => 1)
- , $atts));
- $args = array(
- 'post_type' => 'testimonial',
- 'numberposts' => -1
- );
- global $post;
- $posts = new WP_Query($args);
- $output = '';
- if ($posts->have_posts( $attributes['id']))
- while ($posts->have_posts( $attributes['id'])):
- $posts->the_post();
- $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' );
- $out = '<div class="testimonial-img">
- <img src="'.$url.'" />
- </div>
- <div class="testimonial_content">
- <img src="'.get_field('logo').'" alt="icon">
- <p class="testimonial_desc">'.get_the_content().'</p>
- <div class="author-details">
- <img src="'.get_field('author_image').'" alt="image">
- <p>'.get_field('author_name').' <span>'.get_field('author_designation').'</span></p>
- </div>';
- // add here more...
- $out .='</div>';
- endwhile;
- else
- return; // no posts found
- wp_reset_query();
- return html_entity_decode($out);
- }
Add Comment
Please, Sign In to add comment