Conditional custom field query
I found this: http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query I have modified the date to retrieve the last 15 days. It’s untested, but should work. $expireDays=”15″; $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->posts.post_type=”post” AND $wpdb->posts.post_date >= ( CURDATE() – INTERVAL $expireDays DAY ) ORDER BY $wpdb->posts.post_date DESC “; $pageposts = $wpdb->get_results($querystr, … Read more