Orderings items from a "Post" custom field using WP_Query

Support General Orderings items from a "Post" custom field using WP_QueryResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33582
    AdrienAdrien
    Participant

    Hello,

    I'm using a "Post" custom field with Cloneable and Sortable option.
    In the back-end my client can reorder the items as he wants.

    I would like to know how I can retrieve these items but with the same order as what I have inside my back-end CPT?

    I'm using Oxygen (with the Advanced Query Builder) and I would like to know which option / parameter I need to use to query the items in the same order using WP_Query.

    Thanks!

    #33607
    Long NguyenLong Nguyen
    Moderator

    Hi Adrien,

    To get the posts in the same order as the backend, you can just follow the Template Usage to do https://docs.metabox.io/fields/post/#template-usage

    In case of using Oxygen Builder, please reach out to them if you have any issues with installation, configuration, compatibility, or usage.
    Refer to our support policy https://support.metabox.io/topic/support-policy/

    #33625
    AdrienAdrien
    Participant

    Hi Long,

    Oxygen Builder use the default WP_Query inside the Advanced Query Builder, my question is how to get the same order with a default WordPress WP_Query query?

    Best regards,

    Adrien.

    #33682
    AdrienAdrien
    Participant

    Hello,

    The solution was found with the help of Phe Simmonds (support from Oxygen Builder).
    We just needed to add "orderby": "post__in"

    Like this: https://d.pr/i/PfSrVI

    This thread can be closed and marked as [RESOLVED]

    #40071
    JBPHJBPH
    Participant

    Hi Adrien, I have a similar issue and hope you can help?

    I also have an advanced Query in Oxygen and I am trying to sort my posts by a custom field I added in Metabox.

    I added a number field and have assigned a number to each post. In the query I have tried to do orderby --> data --> and choose the Metabox field but this doesn't work.

    Any ideas would be hugely appreciated!

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