Reciprocal relationships do not follow the order of the admin

Support MB Relationships Reciprocal relationships do not follow the order of the adminResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #19203
    Content PilotContent 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!

    #19215
    Long NguyenLong 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 PilotContent 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 NguyenLong Nguyen
    Moderator

    Hi,

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

    #19227
    Content PilotContent 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 PilotContent 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 TranAnh 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 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.