Support Forum
Support › MB Relationships › How to order relationships in Bricks Builder query loops
When using a relationship in Bricks Builder, I don't see where I'm able to control the order (or number, etc.) of the posts. I've created a field for post order, but that doesn't take affect on the front end. I entered a query arg on the field for orderby, but that only seems to handle the display in the editor for those relationships. Any suggestions would be much appreciated. Thank you!
Hello Keith,
The order of related posts in the frontend should reflect the order of related items in the admin area. Does it work like that on your end? Please try to use the code without the Bricks builder and let me know how it goes.
https://docs.metabox.io/extensions/mb-relationships/#getting-connected-items
Hi Peter,
Forgive the long pause in response to this. Are you saying that there is no way to order the related items by, say, date? I've created a relationship like this:
Artists > Exhibitions (order Exhibitions by date)
Exhibitions > Artists (order Artist A-Z)
Before I do more testing...just making sure I'm on the same page about what is possible.
KC
Hello,
Yes, the order of related items in the frontend should reflect the order of related items in the admin area. You can use the parameter "order, orderby" of WP Query to override the default order of related items.
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
Peter,
In some cases I'm able to order the items, but in this video you can see that it doesn't work smoothly.
https://jam.dev/c/f87be178-ee97-46e3-bffc-c8d3ce12c69e
Additionally, that would be an onerous task were there to be many items.
I've tried using a meta key in Bricks for a date field in the query loop to get the orderby to work, but that hasn't worked either.
Hello,
I've tried using a meta key in Bricks for a date field in the query loop to get the orderby to work, but that hasn't worked either.
As I mentioned in the first reply: Please try to use the code without the Bricks builder and let me know how it goes. Following the documentation https://docs.metabox.io/extensions/mb-relationships/#getting-connected-items
In some cases I'm able to order the items, but in this video you can see that it doesn't work smoothly.
You can try to deactivate all plugins except Meta Box, MB extension plugins, switch to a standard theme of WordPress and check the issue again.