Get CPT, separate into taxonomy terms and style first post different from next 3
-
Hi all,
I am using The Events Calendar on a site and wish to display some of the posts in the jquery carousel shown below.
https://tympanus.net/codrops/2011/08/16/circular-content-carousel/Ideally I’d like a loop that will get all the ‘tribe_events’ posts, then create a separate div for all the terms of the taxonomy ‘tribe_events_cat’. Within each of those boxes, I would like the loop to call the next upcoming event and style it a certain way, then call the next three upcoming events a different way.
In brief the code needs to look something like this:
--------------------- Container for complete carousel <div id="ca-container" class="ca-container"> <div class="ca-wrapper"> --------------------- // THE CUSTOM LOOP THAT CREATES A BOX FOR EACH TYPE OF TERM --------------------- <div class="ca-item CUSTOM IDENTIFIER"> // First Upcoming post of a term <div class="ca-item-main"> FEATURED IMAGE <div> THE TERM TITLE </div> <div> POST TITLE EXCERPT <a href="#" class="ca-more">more...</a> </div> --------------------- Then a container for the next 3 posts: <div class="ca-content-wrapper"> <div class="ca-content"> --------------------- // For each of the next three posts of a term <div> POST TITLE EXCERPT --------------------- Close 3 post containers </div> </div> --------------------- END LOOP Close carousel </div> <div> ---------------------
Does that make sense? If not, let me know.
So far I’ve been playing around with this, but I can’t see how to implement the code the Carousel requires into it:
$terms = get_terms( 'tribe_events_cat', 'hide_empty=0' ); foreach ( $terms as $term ) { $args = array( 'post_type' => 'tribe_events', 'tax_query' => array( array( 'taxonomy' => 'tribe_events_cat', 'field' => 'slug', 'terms' => $term->slug ) ), 'posts_per_page' => 4 ); $query = new WP_Query( $args ); if( $query->have_posts() ) : while( $query->have_posts() ):the_post(); the_title(); endwhile;endif; }
Can anyone help me please?
Many thanks,
Adam.
- The topic ‘Get CPT, separate into taxonomy terms and style first post different from next 3’ is closed to new replies.