Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Sort Posts and Pages by ID Manually in Query Loop

  • I have been replacing WPSP grids on my site with Query Loops. One thing that I liked about WPSP is that with a short code you could specify the order of posts/pages by id. So far, the ASC and DESC sorting order has worked for me, but I am now looking to customize the order of the posts like in WPSP. This is for hotels which I want to display by level from 3 star all the way to deluxe.

    Any suggestions for a non-developer?

  • Hi there,

    You can create a custom field for the posts, for example, a score from 0 to 10.

    Then you can order the query loop using this custom field’s value:
    https://docs.generateblocks.com/article/order-query-loop-by-custom-field/

  • Creating a custom field is not non-developer friendly.

    I figured things out by adding the parameter of “menu order” to the query loop and adding a menu order number for each page that I want to sort in pages/quick edit. Do you see any reasons to not do it this way?

    When either Word Press or Generate Press get updated, will I lose the number that I input in menu order or will these items be saved?

    Please let me know.

    Thanks,

  • Do you see any reasons to not do it this way?

    Pages have menu order, but not posts. As you asked about both posts and pages 🙂

    But yes, you can use PHP code or plugin to enable menu order for posts as well, which is not non-developer friendly as well…

    When either Word Press or Generate Press get updated, will I lose the number that I input in menu order or will these items be saved?

    No, that’s a WP option, theme does not interfere with that.

  • OK. Thanks,

  • No Problem 🙂

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