Of course, right after I post I figure out the problem. You actually need to pass and array of arrays. So my code works now that I changed the code to:
function my_function($branch){
$args = array(
'posts_per_page' => 10,
'post_type' => 'officer_profile',
'meta_query' => array(
array(
'key' => 'asg_branch_gvt',
'value' => $branch
))
);
$officers = new WP_Query($args);
}
Luckily I wasn’t the only one with this problem in the last few hours. 😉 See http://core.trac.ww.wp.xz.cn/ticket/16563 gives details.
I think more than anything, some improvement to the example usage in the query_posts Codex page would help. See the heading “Multiple Custom Field Handling” at http://codex.ww.wp.xz.cn/Function_Reference/query_posts. In fact that code example may be wrong.
Weird, this didn’t work for me.
Rather, this worked as I was working with query_posts.
$args["meta_query"] = array("state"=> array("Delhi", "IN"));