I was having a heck of a time writing a query that would include any posts with a custom field whose value was set to "updated", "new", or null. Unfortunately the method suggested in the codex for WP_Query assumes that there will always be a value in the field. If the field is null, it won't include those posts.

I looked at running a SQL query on the database to fill in those fields, but the wp_postmeta table in Wordpress doesn't seem to have any kind of 1-to-1 relationship to the pages.

After some poking around, I found this great post entitled Querying posts with a false or NULL meta value. I modified the code to match my criteria:

{% highlight php startinline %} function letsmodifythepostswhere( $clause='' ) {
global $wpdb; // Check whether the value is false or NULL. If it is neither, then we want to filter it. $clause .= " AND ( (mypostmeta.metakey = 'updatetype' AND ( CAST(mypostmeta.metavalue AS CHAR) = 'updated' OR CAST(mypostmeta.metavalue AS CHAR) = 'new')) OR mypostmeta.meta_id IS NULL ) "; return $clause; } {% endhighlight %}

I also like how it uses filters to inject SQL instead of modifying the 'meta_query' key, which apparently can cause issues if you have plugins which use that.