If I get it right you are storing this data in user meta. WP_Query
would have no remote idea how to retrieve that, since it’s only aware of post meta. The two are completely separate and there is no native way to involve one in queries for another.
Likely you will have to do this in a two step process:
- Use
get_users()
to retrieve IDs for all authors of one gender and then another. - Use
author__in
argument ofWP_Query
to limit posts to such set of authors.
Working of what you got so far:
$blogusers = get_users( array(
'meta_key' => 'gender',
'meta_value' => 'Homme',
'meta_compare' => '=',
'fields' => 'ID',
) );
$custom_query_args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'post_status' => 'publish',
'author__in' => $blogusers,
'order' => 'DESC',
'orderby' => 'date',
);
$custom_query = new WP_Query( $custom_query_args ); ?>