Advertisement
BakerMan

Calendar widget: specific categories on specific pages

Nov 29th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. // We'll assign the slug of a specific event category to this var
  2. $calendarTerm = null;
  3.  
  4. // Have any of the pages we are interested in been requested?
  5. switch ($wp_query->post->post_name) {
  6.     case 'peewee-schedule': $calendarTerm = 'peewee'; break;
  7.     case 'bantam-schedule': $calendarTerm = 'bantam'; break;
  8.     case 'midget-schedule': $calendarTerm = 'midget'; break;
  9. }
  10.  
  11. // Basic query
  12. $calendarQuery = array('eventDisplay' => 'month');
  13.  
  14. // Create and use a tax query if we have a calendar term
  15. if ($calendarTerm !== null) {
  16.     $taxonomyQuery = array('tax_query' => array(array(
  17.         'taxonomy' => TribeEvents::TAXONOMY,
  18.         'field' => 'slug',
  19.         'terms' => $calendarTerm
  20.     )));
  21.  
  22.     $calendarQuery = array_merge($taxonomyQuery, $calendarQuery);
  23. }
  24.  
  25. $eventPosts = tribe_get_events($calendarQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement