I'm trying to write a
wp_query that will filter out posts with a certain tag only if they are also 1 month old. All posts older then a month without the tag are displayed and any post less then a month old is displayed.
After learning about date_query from a pervious post this was my attempt. However I found that
post__not_in needs an
ID, and OR relations are for
meta_queries but I just want a regular query with 2 sets of possible solutions. Either A it doesn't have the tag and time doesn't matter, or b it has the tag and after a month it is no longer displayed. Alternatively is there a way I can just write SQL to do this?
$onemonth_before = date( 'Y-m-d', strtotime('-1 month')); $args = array( 'post__not_in' => array( 'tag' => 'x-post', 'date_query' => array( 'before' = $onemonth_before, 'inclusive' = true, ), ), ); $query = new WP_Query( $args );