Skip to content

Instantly share code, notes, and snippets.

@chibani
Created January 11, 2012 16:04
Show Gist options
  • Save chibani/1595359 to your computer and use it in GitHub Desktop.
Save chibani/1595359 to your computer and use it in GitHub Desktop.
WordPress : Load custom posts using their custom fields
//WordPress Query to load custom posts using their custom fields
$myquery = new WP_Query(array(
'post_type' => 'mycustom',
'posts_per_page' => 15,
'orderby' => 'meta_value',
'meta_key'=>'mycustom_date_start',
'order' => 'ASC',
'meta_query'=>array(
'relation'=>'AND',
array(
'key' => 'mycustom_date_start',
'value' => date('Y-m-d'),
'compare' => '>=',
'type' => 'DATE'
)
)
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment