<?php// Query Posts of custom post type carousel using Foundation 6's Orbit and Advanced Custom Fields for an optional redirect$the_query=newWP_Query(array('post_type'=>'carousel','orderby'=>'date','order'=>'DESC','posts_per_page'=>5,));// The Loopif($the_query->have_posts()){?><divclass="orbit"role="region"aria-label="Slideshow"data-orbitdata-use-m-u-i="false"><ulclass="orbit-container"><buttonclass="orbit-previous show-for-medium"aria-label="previous"><spanclass="show-for-sr">Previous Slide</span>◀</button><buttonclass="orbit-next show-for-medium"aria-label="next"><spanclass="show-for-sr">Next Slide</span>▶</button><?phpwhile($the_query->have_posts()){$the_query->the_post();echo' <li class="orbit-slide"> <div>';// check if the post has a Post Thumbnail assigned to it.if(has_post_thumbnail()){// check if redirect is set$redirect=get_field('redirect_to_url');if(''!=$redirect){echo'<a href="'.$redirect.'">';}the_post_thumbnail('carousel',['class'=>'orbit-image','loading'=>false]);if(''!=$redirect){echo'</a>';}$my_excerpt=get_the_post_thumbnail_caption();if(''!=$my_excerpt){echo'<figcaption class="orbit-caption">'.$my_excerpt.'</figcaption>';}}echo'</div> </li>';}/* Restore original Post Data */wp_reset_postdata();?></ul></div><?php}else{// no posts found}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.