Created
April 11, 2018 15:25
-
-
Save ben-heath/b5cdba0ea0886c628f5b25916598e173 to your computer and use it in GitHub Desktop.
Shortcode list CPT posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode( 'video-testimonials', 'sls_video_testimonial_short_code' ); | |
function sls_video_testimonial_short_code( $atts ) { | |
ob_start(); | |
$query = new WP_Query( array( | |
'post_type' => 'video-testimonial', | |
'posts_per_page' => 4, | |
'order' => 'ASC', | |
'orderby' => 'title', | |
) ); | |
if ( $query->have_posts() ) { ?> | |
<div class="vid-testimonials"> | |
<?php while ( $query->have_posts() ) : $query->the_post(); ?> | |
<div class="indv_vid_test"> | |
<h3> | |
<?php the_title(); ?> | |
</h3> | |
<p class="the_date"> | |
<?php the_field("video_date"); ?> | |
</p> | |
<div class="the_video"> | |
<?php echo wp_oembed_get(get_field("video_url"), array('width'=>295)); ?> | |
</div> | |
</div> | |
<?php endwhile; | |
wp_reset_postdata(); ?> | |
</div> | |
<div class="clearfix"></div> | |
<p id="more-vids"><a href="/video-testimonial/">View more</a></p> | |
<?php $myvariable = ob_get_clean(); | |
return $myvariable; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment