Custom Fields
Re-Envisioned
Support MB Relationships WP_Query options no longer work in MB Relationships 1.10.1

  • Creator
    Topic
  • #20672
    Resolved William E White
    Participant

    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://metabox.io/support/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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #20697
    Long Nguyen
    Moderator

    Hi,

    Please update the plugin MB Relationships to v1.10.3 or MB AIO to v1.11.15 to fix this issue. Thank you.

    #20709
    William E White
    Participant

    This update appears to have fixed the issue. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.