Created
June 16, 2012 15:57
-
-
Save zanematthew/2941765 to your computer and use it in GitHub Desktop.
Code from the Home page controller
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 | |
public function randomBanner(){ | |
$obj_local_venues = new Tracks; | |
$local_venues = $obj_local_venues->getLocalVenues(); | |
$venue_ids = array(); | |
foreach( $local_venues as $venue ){ | |
$venue_ids[] = $venue->ID; | |
} | |
$random_venue_id = Helpers::makeRandom( $venue_ids ); | |
$args = array( | |
'post_type' => 'events', | |
'posts_per_page' => 1, | |
'meta_query' => array( | |
'relation' => 'AND', | |
array( | |
'key' => 'bmx_re_start_date', | |
'value' => array( date('Y-m-d'), Helpers::plusMonth(6)), | |
'type' => 'DATE', | |
'compare' => 'BETWEEN' | |
), | |
array( | |
'key' => 'tracks_id', | |
'value' => $random_venue_id, | |
'compare' => '=' | |
) | |
) | |
); | |
$query = new WP_Query( $args ); | |
$event = null; | |
if ( $query->post_count == 0 ) { | |
$event = false; | |
} else { | |
foreach( $query->posts as $post ){ | |
setup_postdata( $post ); | |
$event['title'] = $obj_local_venues->getMetaField( 'state', $random_venue_id ) . ' ' . $post->post_title; | |
$event['link'] = "/events/" . $post->post_name; | |
$event['date'] = Helpers::formatDate( $post->ID ); | |
} | |
} | |
return $event; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment