Site logo

[Support request] Sorting GB Query Loop

Home Forums Support [Support request] Sorting GB Query Loop

Home Forums Support Sorting GB Query Loop

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2214762
    Takeru

    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?

    #2214924
    David
    Staff
    Customer Support

    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 🙂

    #2214967
    Takeru

    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?

    #2215031
    David
    Staff
    Customer Support

    The number field is assigned by contract plan

    Is this a Custom Field ?

    #2215581
    Takeru

    Yes.

    #2215992
    David
    Staff
    Customer Support

    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.

    #2216003
    Takeru

    I understand.
    I look forward to it.

    Thank you.

    #2216030
    David
    Staff
    Customer Support

    You’re welcome – and thank you for your feedback

    #2428796
    Sascha

    “Custom Field query args are something we will be adding to the Pro version in the future.”

    is this added already?

    #2428918
    David
    Staff
    Customer Support

    Hi there,

    no.

    If advanced query args are required, you can use the generateblocks_query_loop_args filter.
    See for a related example:

    https://generatepress.com/forums/topic/query-loop-use-acf-date-field-as-order-by-parameter/#post-2406193

    #2428938
    Sascha

    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?

    #2428945
    David
    Staff
    Customer Support

    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.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.