WP Query ordering on a meta field for posts with a date in the future not ordering by datetime

The docs are a little vague in this area, but it should be possible to define your ordering value more succinctly: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 5, ‘category__in’ => $postCategories, ‘meta_query’ => array( array( ‘key’ => ‘ordering_date’, ‘value’ => date(“Y-m-d H:i:s”), ‘compare’ => ‘>=’, ‘type’ => ‘DATETIME’, ), ), … Read more

meta queries do ‘either/or’ checks

meta_query works on ‘both/and’ checks and also ‘either/or’.so don’t worry.your coding was correct.this is the actual format… $a = new WP_Query( array( ‘fields’ => ‘ids’, ‘ignore_sticky_posts’ => true, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘foo’, ‘value’ => array( ‘foobar’ ), ‘compare’ => ‘IN’ ), array( ‘key’ => ‘bar’, ‘value’ => array( ‘foobar2’ … Read more

Search by meta_query

You should look into meta_query: $args = array( ‘meta_query’ => array( ‘key’ => ‘event_start_timestamp’, // the name of the meta ‘value’ => ’11/21/2011′, // the value to search for ‘compare’ => ‘>=’, //search for start dates bigger or equal to value ) ); $query = new WP_Query( $args );

Create an archive listing based on meta array

Have you looked at PHP’s date function? A quick example : $dates = $wpdb->get_col( /*your sql*/ ); if( $dates ) { $archive_year = “”; foreach( $dates as $date ) { $the_date = strtotime( $date ); $year = date( ‘Y’, $the_date ); //4 digit year, ex 1999 $month = date( ‘F’, $the_date ); //Full textual month, … Read more

Query posts by Author and/or by Tag

Your first query is very strange. You seem to be mixing meta_query parameters with other WP_Query arguments. You can’t do that. author is not a valid component of a meta_query, neither is tag. The correct meta_query, if I am interpreting this right, wouldn’t even be a meta query. You are dealing with a taxonomy, a … Read more

Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months

First of all I don’t think you should use your custom query_posts in here. WordPress already queries posts on archive pages, so it’s waste of time to query them one more time. You should be using pre_get_posts filter. function my_pre_get_posts($query) { if (!is_admin() && is_main_query() ‘<YOUR_POST_TYPE>’ === $query->query_vars(‘post_type’) && $query->is_archive()) { $query->set(‘orderby’,’meta_value’); $query->set(‘meta_key’, ‘<YOUR_POST_TYPE>’); //formatted … Read more