I have a custom post type for a cycling club uses to schedule rides. There is a custom field for these posts where the user selects the "ride date" with JQUI date & time picker. This information is stored as such in postmeta:
07/26/2012 @ 12:00 am
I query these posts with:
query_posts(array('posts_per_page' => 3, 'post_type' => 'rides');
But we don't want rides that already happened to display:
//Format User entered ride date $date = get_post_meta($post->ID, 'date', true); $date = str_replace(' @ ', ' ', $date); //adjust unix timestamp $time = time() -21600; //If ride has not already happened, print it. if ( $time < strtotime( $date ) ):
That sort of works, but there is a fundamental flaw that a more seasoned PHP dev will likely see almost immediately. In my query I'm fetching the last three posts based on POST DATE and then testing the meta value to see if the rides already happened or not. What I really need to do is take a step back and test wether a ride has already happened in my query.