I have a news article post type with an attribute called "news_publish_year_hidden" which stores a year, such as 2009. I am trying to write a query to get all the articles written in 2009 and 2012. The code does not work and it returns all the news articles if I try to sort the results by another custom attribute called "news_publish_date_hidden" which stores a timestamp.
The following is my query:
$myArray = array( 'relation' => 'OR', array( 'key' => 'news_publish_year_hidden', 'compare' => '=', 'value' => '2009' ), array( 'key' => 'news_publish_year_hidden', 'compare' => '=', 'value' => '2012' ) ); $news = new WP_Query( array( 'post_type'=>'news', 'meta_key' => 'news_publish_date_hidden', 'order' => DESC, 'orderby' =>meta_value', 'paged'=>get_query_var('paged'), 'posts_per_page'=>'2', 'meta_query' => $myArray ) );