WordPress.org

Support

Support » Themes and Templates » Meta_query on custom post

Meta_query on custom post

  • I am trying to use a custom query to retrieve set of events (custom post type) that are happening either today or in the future.

    I have a custom field that I’m using (stored as ‘yyyymmddhhmm’ for sorting but the meta_query doesn’t seem to be working. Would anyone be able to tell me where I am going wrong?

    $query_args = array(
    	'post_type' => 'events',
    	'meta_key' => 'start_sort_timestamp',
    	'meta_query' => array(
    		array(
    			'meta_key' => 'start_sort_timestamp',
    			'meta_value' => 201203051100,
    			'compare' => '>=',
    			'type' => 'NUMERIC'
    		)
    	),
    	'orderby' => 'meta_value',
    	'order' => 'ASC'
    );
    
    $query = new WP_Query( $query_args );
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Meta_query on custom post’ is closed to new replies.
Skip to toolbar