Problem: I am trying to use a meta_query with the post relationships API toolset_get_related_posts, but it doesn't seem to be filtering as expected.
Solution: Some complex meta_queries, like using "IN" or "AND" with more than one term, fail with the post relationships API. Instead, you should use a standard WP_Query and add the toolset_relationships clause:
$args = array( 'numberposts' => -1, 'post_type' => 'child-post-type-slug', 'orderby' => 'post_date', 'order' => 'DESC', 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'wpcf-colour', 'value' => 'Red', 'compare' => '=' ), array( 'key' => 'wpcf-description', 'value' => 'Ball', 'compare' => '=' ) ), 'toolset_relationships' => array( 'role' => 'child', 'related_to' => $post_id, 'relationship' => 'relationship-slug' ), ); $child_query = new WP_Query( $args );
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 4 years, 8 months ago.
Assisted by: Christian Cox.