Order relationship Options by ASC
Support › MB Relationships › Order relationship Options by ASC
- This topic has 7 replies, 2 voices, and was last updated 2 years, 11 months ago by
Long Nguyen.
-
AuthorPosts
-
April 28, 2022 at 4:52 PM #35815
Yasmine
ParticipantHello, my
relationship
choices are showing the order that they were added, rather than alphabetical. I have tried toorderby
but not working. How do I make the relationship options orderby ASC post-title, and what and where do I add this into the relationship settings? CheersApril 28, 2022 at 10:26 PM #35818Long Nguyen
ModeratorHi,
There is an issue with the setting
query_args
of the relationship, it is fixed in this commit https://github.com/wpmetabox/mb-relationships/commit/7e9505be0b3fc2ac69a1fc1ffba714cb4ede41f8You can download this branch to your site and follow the documentation to use the query_args with coding
https://docs.metabox.io/extensions/mb-relationships/#using-codeMB_Relationships_API::register( [ 'id' => 'job-to-post', 'from' => [ 'object_type' => 'post', 'post_type' => 'job', 'field' => [ 'query_args' => [ 'orderby' => 'title', 'order' => 'ASC' ] ] ], 'to' => [ 'object_type' => 'post', 'post_type' => 'post', 'field' => [ 'query_args' => [ 'orderby' => 'title' ] ] ], ] );
April 30, 2022 at 5:38 PM #35836Yasmine
ParticipantThank you Long!
And sorry for being a newbie, but I added the 'commit' to my php files and changed the orderby to just 'title' in the relationship query_args. But it didn't work. Did I do what you suggested correctly?
May 3, 2022 at 7:27 AM #35848Long Nguyen
ModeratorHi,
It works as well on my local site, please check this screen record https://monosnap.com/file/33zS6ArE3QpKkSKAC2m06os1nYlpvJ
June 10, 2022 at 4:45 AM #36408Yasmine
ParticipantHi Long,
Still can't get this one working. I think that I did not get the commit working, as the php code does not look right:
<?php add_action( 'mb_relationships_init', 'your_prefix_function_name' ); function your_prefix_function_name() { MB_Relationships_API::register( [ 'id' => 'university_user', 'from' => [ 'object_type' => 'post', 'post_type' => 'university', 'field' => [ 'query_args' => [ '5w1x2lx5oq7' => [ 'id' => '5w1x2lx5oq7', 'key' => 'orderby', 'value' => 'title', ], 'og7o0qgfecd' => [ 'id' => 'og7o0qgfecd', 'key' => 'order', 'value' => 'ASC', ], ], 'max_clone' => '1', ], ], 'to' => [ 'object_type' => 'user', 'post_type' => 'post', 'taxonomy' => 'category', 'field' => [ 'query_args' => [ 'iqoxqzev60p' => [ 'id' => 'iqoxqzev60p', 'key' => 'orderby', 'value' => 'title', ], 'mo9n62730iq' => [ 'id' => 'mo9n62730iq', 'key' => 'order', 'value' => 'ASC', ], ],
June 10, 2022 at 12:41 PM #36422Long Nguyen
ModeratorHi,
This issue has been fixed in the new version of MB Builder, MB AIO. You can remove the code in that commit, update the extension and re-check the issue.
June 10, 2022 at 3:32 PM #36429Yasmine
ParticipantThanks Long, I am up to date with the latest MB AIO - but still face the same issue. I have tried to delete re-add etc..
Currently I am just adding
orderby
andorder
into thequery_args
on the relationship. I have also additionally added it into settings incustom fields
. But with this too, it still is not working.Is there something I am missing? Or could I have a setting that is overwriting this?
Many thanks!
June 11, 2022 at 2:47 AM #36444Long Nguyen
ModeratorHi,
You can try to switch to the standard theme of WordPress (Twenty TwentyTwo) and deactivate all plugins except Meta Box, MB extensions then recheck this issue. See how it works on my end https://monosnap.com/file/As4Qk5fWuYQzLgPI1DMBgOeqUeC7ev
-
AuthorPosts
- You must be logged in to reply to this topic.