Skip to content

Instantly share code, notes, and snippets.

@rgsmith1980
Last active December 16, 2015 23:19
Show Gist options
  • Save rgsmith1980/5513583 to your computer and use it in GitHub Desktop.
Save rgsmith1980/5513583 to your computer and use it in GitHub Desktop.
WordPress query_posts by meta field for custom post type
query_posts(array(
'post_type' => 'your-post-type-here',
'meta_key' => 'your-meta-key-name',
'meta_query'=> array(
array(
'key'=>'your-meta-key-name',
'value'=> 'your-search-val',
'compare' => '='
)),
'orderby' => 'meta_value_num',
'order' => 'ASC'
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment