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 ); ?>
Related Posts:
- Meta_query on same meta key, with diffrenct values
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Query multiple meta values
- Why isn’t my `meta_query` array functioning properly?
- How to orderby multiple meta fields if some fields are empty
- Meta Query relation “AND” then set array accordingly
- WP Query Meta Value – How To Identify Specific, Unique Values?
- Meta query with compare by more than 2 fields
- Order (by ASC) posts with meta_key so posts without values are last
- wp query to use both author id and meta_query
- Counting instances of words in the results of a post query
- WP_Query multiple value not working
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Unusual high query of user meta data
- How to delete only user meta value (not key) from usermeta table in wordpress?
- Get posts by meta value except one post [closed]
- Get all user with both meta_value
- How to query posts based on lat-lng coordinate as post meta?
- Set Alias for meta_query arguments in get_posts()
- Add indexing to meta_value in wp_postmeta
- Custom WP_Query order by post_meta and (author) user_meta
- Getting all user metadata from user
- Using custom meta_query with relation not working as expected
- Perform query with meta_value date
- WP_Query meta_query where meta value ends in space
- Nested query inside Logical operator OR not working in meta_query
- What is an efficient way to query based on post_meta?
- How do I create my own nested meta_query using posts_where / posts_join?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Exclude post on loop by multiple meta key value
- Querying by taxonomy vs Querying by Custom fields Speed Comparison
- meta_key and meta_value not working together
- Order posts by meta value and Date
- Query sticky posts with thumbnails
- Only display authors who have posts
- Order WP Query posts by custom order calculated from post meta values
- how to speed up a complex wp_query?
- Meta query with order by another custom field
- How to query for custom field within Gutenberg block from outside of that post? [closed]
- Meta query with JSON value
- Get meta info related to current post
- Creating arguments from loop for WP_Query meta_query
- Order a query result by a numeric meta key even if it does not exist, but put the posts with meta key first
- Single meta_query query using OR instead of AND in request’s WHERE statement
- Need wp_query to return all children and grandchildren
- How to do meta_query for attachments?
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- new WP_Query to get max price meta value not working
- Using meta_query with multiple keys and compare values
- Overwrite YoastSEO meta-tags with another page’s [closed]
- Suggestions on making this query/code more performant
- Is it possible to set specific posts to show first in a query?
- Dynamic User Id
- Order by meta value (numeric value lower to higher)
- Large AND OR query timing out
- WP_Query with different postmeta filter for each categories
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Meta Query doesn’t works as espected
- Advanced WP_Query with meta_query, orderby?
- Issues with search after added meta_query
- Display posts with specific value first in query
- WP_Query: apply an SQL function to meta fileld value
- How to search for meta_query LIKE or tax_query LIKE and grab these posts on search results?
- How to create dynamic value in WP_Query meta_query
- How can i show pagenavi in my author.php?
- WP_Query meta compare must include ALL array values
- meta_query returning excluded result
- What’s missing in this wp_query and meta_query
- meta_query weird behaviour, static int will work, but not user data
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Query posts by post type, author and post meta
- Usermeta data unserialize, extract and display in table in WordPress
- Trouble with serialized metadata
- meta_query order by date present -> future then show null
- Get authors list and sort them by recent posts
- meta_query compare > not working
- meta_query is not allowing to show posts when querying multiple arguments in a WP_Query
- Speed up WP_query with meta comparing dates
- Saving custom fields for WP_Query to retrieve
- Is it possible to search for a string in posts OR postmeta?
- Filter posts/pages by user_role array
- WP_Query with MetaQuery issue
- WP_Query Posts by Metadata from Option Tree
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- WP_Query within save_post doesn’t include the item that triggered the action?
- WP_Query with meta_value_num and meta_query not paged correctly
- Post Query not working after updating to 4.1
- Cannot order by in WP_Query
- Orderby Meta Value and Query from Meta Query
- The sorting of posts by a meta_query with two keys fails while separated as single queries it works
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- Sort Posts with custom meta key by default which is currently set as optional
- WP_Query with several meta_query-statements and order by meta_value
- query_posts, oderby meta_value & print “future” posts
- How to get all post_id and meta_value using meta_key in wp_postmeta table
- WP Query – Show custom posts only if user contain some user meta
- How do I subquery with custom meta fields?
- Showing Counts on Comment List with Custom Query