Custom Fields
Re-Envisioned
Support MB Relationships Reciprocal relationships do not follow the order of the admin

  • Creator
    Topic
  • #19203
    Resolved Content Pilot
    Participant

    Hi Anh,

    When I get the reciprocal relationship fields they seem sorted by post_date and they no longer follow the admin order.

    Admin
    Frontend

    new WP_Query(
        array(
            'relationship'   => array(
                'id'   => 'posts_to_posts',
                'to' => get_the_ID(),
            ),
            'nopaging'     => true,
        )
    );

    Cross relationship fields works fine. I’m not sure if there are any additional parameters that I need to add to get the administrator order. Thanks!

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

    Hi,

    You can add the parameters order and order_by to the query to sort the posts. For more information, please follow this documentation
    https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters

    #19217
    Content Pilot
    Participant

    Thanks for the answers Long,

    That’s fine, but I can’t sort by wp_mb_relationships’s order_from with native parameters. Also, I’m not sure that’s the correct behavior, cross relationships reflect the admin order.

    I might think it should be set here, but give me a hint if you think I can help you.

    #19220
    Long Nguyen
    Moderator

    Hi,

    Thank you, I’m going to check it out and let you know later.

    #19227
    Content Pilot
    Participant

    Long,

    I submitted a pull request with an update that worked for me, so you can check or improve it when you have a chance.

    Thank you

    #19866
    Content Pilot
    Participant

    Hi,

    Have you had an opportunity to review the PR? I’ve been using it and it works fine, but it would be nice at some point check it out or merge it to the stable version.

    Thanks

    #19943
    Anh Tran
    Keymaster

    Hi,

    I commented on the PR. Let’s keep discussing over there for better reference of the code.

    Thanks for your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash