Query posts using author custom meta
-
I have a custom user meta field called ‘county’
I have a custom post type called ‘classes’I want to query classes by all users whose ‘county’ meta is the same as the page ID.
Where I’m stuck is the post query. I’m using ‘author__in’ which expects an array of user ID’s. How do I do a user query here that will return an array of ID’s?
$this_county = $post->post_name; //Use the ID of this page to determine which county we need $user_query = new WP_User_Query( array('meta_key' => 'county', 'meta_value' => $this_county) ); //Find users whose county is set to this county $args = array('author__in' => $user_query, 'post_type'=>'classes'); //Find classes by matched users
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘Query posts using author custom meta’ is closed to new replies.