Skip to main content
added 217 characters in body
Source Link
ptriek
  • 857
  • 1
  • 8
  • 14

I recently did exactly the same, you'll have to use custom query:

                 $date = time()-86400; /* today */
                 $querystr = "
                    SELECT $wpdb->posts.* 
                    FROM $wpdb->posts, $wpdb->postmeta
                    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
                    AND $wpdb->posts.post_status = 'publish' 
                    AND $wpdb->postmeta.meta_key = 'event_date' 
                    AND $wpdb->postmeta.meta_value > " . $date . " 
                    ORDER BY $wpdb->postmeta.meta_value ASC
                 ";

                
                 $pageposts = $wpdb->get_results($querystr, OBJECT);
                 foreach ($pageposts as $post):
                 /* etcetera */

Hope it helps...

Code for changing dd/mm/yyyy to unix timestamp:

$date = explode ('/',$date);
$date = $date[1].'/'.$date[0].'/'.$date[2]; // dd/mm/yyyy to mm/dd/yyyy
$date  = strtotime($date); /* UNIX TIMESTAMP */

I recently did exactly the same, you'll have to use custom query:

                 $date = time()-86400; /* today */
                 $querystr = "
                    SELECT $wpdb->posts.* 
                    FROM $wpdb->posts, $wpdb->postmeta
                    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
                    AND $wpdb->posts.post_status = 'publish' 
                    AND $wpdb->postmeta.meta_key = 'event_date' 
                    AND $wpdb->postmeta.meta_value > " . $date . " 
                    ORDER BY $wpdb->postmeta.meta_value ASC
                 ";

                
                 $pageposts = $wpdb->get_results($querystr, OBJECT);
                 foreach ($pageposts as $post):
                 /* etcetera */

Hope it helps...

I recently did exactly the same, you'll have to use custom query:

                 $date = time()-86400; /* today */
                 $querystr = "
                    SELECT $wpdb->posts.* 
                    FROM $wpdb->posts, $wpdb->postmeta
                    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
                    AND $wpdb->posts.post_status = 'publish' 
                    AND $wpdb->postmeta.meta_key = 'event_date' 
                    AND $wpdb->postmeta.meta_value > " . $date . " 
                    ORDER BY $wpdb->postmeta.meta_value ASC
                 ";

                
                 $pageposts = $wpdb->get_results($querystr, OBJECT);
                 foreach ($pageposts as $post):
                 /* etcetera */

Hope it helps...

Code for changing dd/mm/yyyy to unix timestamp:

$date = explode ('/',$date);
$date = $date[1].'/'.$date[0].'/'.$date[2]; // dd/mm/yyyy to mm/dd/yyyy
$date  = strtotime($date); /* UNIX TIMESTAMP */
Source Link
ptriek
  • 857
  • 1
  • 8
  • 14

I recently did exactly the same, you'll have to use custom query:

                 $date = time()-86400; /* today */
                 $querystr = "
                    SELECT $wpdb->posts.* 
                    FROM $wpdb->posts, $wpdb->postmeta
                    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id 
                    AND $wpdb->posts.post_status = 'publish' 
                    AND $wpdb->postmeta.meta_key = 'event_date' 
                    AND $wpdb->postmeta.meta_value > " . $date . " 
                    ORDER BY $wpdb->postmeta.meta_value ASC
                 ";

                
                 $pageposts = $wpdb->get_results($querystr, OBJECT);
                 foreach ($pageposts as $post):
                 /* etcetera */

Hope it helps...