How to correctly call custom field dates into a posts_where filter using SQL statements
Thanks to AmbitiousAmoeba for the answer. The following improved code solves the problem: function filter_where( $where=”” ) { global $wpdb; $where .= ” AND (($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value >= ‘2000-01-01’) AND ($wpdb->postmeta.meta_key = ‘original_date’ AND $wpdb->postmeta.meta_value <= ‘2004-12-31’)) “; return where; } add_filter(‘posts_where’, ‘filter_where’); query_posts($query_string); while (have_posts()) : the_post(); the_content(); endwhile;