I have a relationship field "assigned_brands" on Stylist Post type that returns an array of the associated Brands post type. I want to query based on the count of assigned_brands . For example I want to get only the the Stylists that have between 1-3 assigned brands or get the stylists that have 10 or more brands assigned
Do you have any idea what filter I must use to be able to use a meta query ?
Thank you all in advance Kind regards John
You cant achieve what you would like without one more custom field. Use a function like the one below to store to a different field the count() of your relationship field.
Then you can use the WP_Query class to query this extra custom field.
Everything above is not tested, but they seem ok to me and it should work!