My site has a reciprocal relationship configured with episodes belonging to podcasts (custom post types created with Meta Box).
After the release of MB Relationships 1.10.1, episodes failed to return in the correct order in my template. No matter what parameters are supplied to WP_Query, results always come back ordered by post date ascending. Passing order
, orderby
, or suppress_filters
to WP_Query had no effect. Did something change in 1.10.1 that I need to adjust for?
Reverting to MB Relationships 1.10.0 corrected the issue, but now we're frozen at that version, and upgrading seems impossible until that is resolved.
I noticed a number of changes following the pull request in this thread. Might they be related?
https://support.metabox.io/topic/reciprocal-relationships-do-not-follow-the-order-of-the-admin/
Here's some sample code from my project:
<?php // setup relationship
function podcasts_to_episodes_relationship () {
MB_Relationships_API::register( array(
'id' => 'podcasts_to_episodes',
'reciprocal' => true,
'from' => array(
'object_type' => 'post',
'post_type' => 'episode',
'admin_column' => true,
'meta_box' => [
'title' => 'Podcast',
],
),
'to' => array(
'object_type' => 'post',
'post_type' => 'podcast',
'admin_column' => false,
),
));
}
<?php // query for episodes belonging to a podcast
$connected = new WP_Query( [
'relationship' => [
'id' => 'podcasts_to_episodes',
'from' => get_the_ID()
]
])
Thanks!