Advertisement
Guiant

Upcoming & taxonomy

Oct 10th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. global $post;
  3. $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  4.  
  5. $args_events = array(
  6.   'post_status'     =>'publish',
  7.   'post_type'       => array(TribeEvents::POSTTYPE),
  8.   'tax_query'       => array(
  9.     array(
  10.       'taxonomy'=>  TribeEvents::TAXONOMY,
  11.       'field'   =>  'slug',
  12.       'terms'   =>  'sweden'
  13.     )
  14.   ),
  15.   'list'            => 'upcoming',
  16.   'posts_per_page'  => 6,
  17.   'paged'           => $paged
  18. );
  19.  
  20. $all_events = new WP_Query();
  21. $all_events->query($args_events);
  22.  
  23. if ($all_events->have_posts()) :
  24.   while($all_events->have_posts()) :
  25.     $categories = '';
  26.     $all_events->the_post();
  27.     $categories = get_categories(
  28.       $category_args = array(
  29.         'taxonomy'  =>  TribeEvents::TAXONOMY
  30.       )
  31.     );
  32.     $categories_name = '';
  33.     foreach ($categories as $category) {
  34.       $categories_name .= $category->name;
  35.     }
  36.     ?>
  37.     <article class="col-md-4">
  38.       <div>
  39.         <span class="date"><?php echo implode('<br />', explode(' ',tribe_get_start_date($post->ID, true, 'd M Y'))); ?></span>
  40.         <?php
  41.         if(has_post_thumbnail()){
  42.           the_post_thumbnail('thumbnail');
  43.         }
  44.         ?>
  45.         <h2><?php the_title(); ?></h2>
  46.         <p><?php the_excerpt(); ?></p>
  47.         <footer>
  48.           <span><?php echo $categories_name; ?></span>
  49.           <a href="<?php the_permalink(); ?>" class="btn btn-primary pull-right">Read more&hellip;</a>
  50.         </footer>
  51.       </div>
  52.     </article>
  53.   <?php
  54.   endwhile; //endwhile
  55. endif;
  56. wp_reset_query();
  57. wp_reset_postdata();
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement