First, it is very difficult to compare dates unless they are in the format yyyy-mm-dd.
Did you want SQL code to remove the posts so you could use phpMyAdmin or a similar tool? Or, do you want to not retrieve those dates in a query, but retrieve others (I think this is what you mean)? That is, only retrieve posts where those dates are in the future.
And, by ‘past todays date’ do you mean the date is earlier than today?
I guess the date could be changed around before the query.
What i am trying to do is list all custom posts that have the custom date field stating a date after the current date. Basically i have a list of holidays and once the departure date for the holiday has passed i no longer need them to be listed, the idea being the posts are still there but wont be visable until an admin changes the dates for the next time that holiday will take place, then it will re appear in the listing with the ammended date.
The holidays come under 4 different custom post types as explained earlier and each carries a departure date “ukhol_ddate_meta” (for the ukhol post type).
Hope that makes sense.
I have all my custom post types defined in my function.php file and my post list is in my index.php file, i have a line of code in my function.php which allows posts, ukhol, holabroad, specevent & daybreak post types to be visible when viewing the index.php, which works fine, i just need to ommit any holidays thats departure date has passed.
If the date fields are in yyyy-mm-dd format, the posts can be listed with a query like this (I can’t test this so watch for typos):
$today = date('Y-m-d');
$args = array(
'post_type' => 'ukhol',
'meta_key' => 'ukhol_ddate_meta',
'meta_value => $today,
'meta_compare' => '>',
'posts_per_page' => -1
);
query_posts($args);
if (have_posts()) {
while (have_posts()) {
the_post();
// Put code here to display the poat
}
} else {
// Put code here for 'no posts found'
}