/ Published in: PHP
First you have to add a custom value with a correct date format.
The lines:
`AND CAST(wpostmeta.meta_value AS DATE) > '".date("Y-m-d H:i:s")."'
AND CAST(wpostmeta.meta_value AS DATE) < '".date("Y-m-d H:i:s", $date2)."' `
are only used to select dates between the current day and 2 months later
The lines:
`AND CAST(wpostmeta.meta_value AS DATE) > '".date("Y-m-d H:i:s")."'
AND CAST(wpostmeta.meta_value AS DATE) < '".date("Y-m-d H:i:s", $date2)."' `
are only used to select dates between the current day and 2 months later
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$myrows = $wpdb->get_results(" SELECT wposts.post_title, wposts.ID , wpostmeta.meta_key, wpostmeta.meta_value FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wposts.post_type = 'concerts' AND wpostmeta.meta_key = 'DateConcert' AND CAST(wpostmeta.meta_value AS DATE) > '".date("Y-m-d H:i:s")."' AND CAST(wpostmeta.meta_value AS DATE) < '".date("Y-m-d H:i:s", $date2)."' AND wposts.post_status = 'publish' ORDER BY CAST(wpostmeta.meta_value AS DATE) ASC "); if ($myrows) : foreach ($myrows as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <?php endforeach; else : ?> <h2> Not Found</h2> <?php endif; ?>
URL: http://www.kune-studio.com