Archived topic
Sorting GB Query Loop
11 replies · Started by Takeru on May 9, 2022
I would like to reorder the GB Query Loop in order of the number field of the post meta, and randomly within that number.
Is there a way to do this?
Hi there,
menu order was added to the latest alpha release - see here:
https://github.com/tomusborne/generateblocks/issues/429
Randomly - i am not sure how that works with the posts in menu order ?
You can raise an issue on the above github page if you want to suggest any features. Its worth searching the Issues first to see if there are duplicates.
Or feel free to reply here :)
Thanks David.
I would like to sort the postings in order of the value of the number field and randomly display within the same number.
This will be used for information posting services such as real estate and job postings.
The number field is assigned by contract plan, so the postings with the lowest number in the number field will be displayed at the top, and the postings within the same contract plan will be displayed randomly to maintain fairness.
To achieve this, do I need to write some php code after setting the menu order in the GB Query Loop?
The number field is assigned by contract plan
Is this a Custom Field ?
Yes.
Custom Field query args are something we will be adding to the Pro version in the future.
Orderby Random ill see if that also can be included in the arguments.
I understand.
I look forward to it.
Thank you.
You're welcome - and thank you for your feedback
"Custom Field query args are something we will be adding to the Pro version in the future."
is this added already?
Hi there,
no.
If advanced query args are required, you can use the generateblocks_query_loop_args filter.
See for a related example:
Thanks, I have added the filter you've linked via code-snippets, but it's not working, check this page.
Any idea whyhow to fix this?
Can you raise a new topic and explain what it is you want to do, and then we can review if a) thats possible and b) what code is required.