0

I'm attempting to mimic 'sticky' functionality on a custom post type using a simple ACF true/false field. I'd like to use pre_get_posts to modify my query to first show my 'sticky' posts at the top and then loop through the rest, excluding the sticky ones.

I understand how to exclude posts by ID or by meta value from the query but am stuck on a good way to show the sticky ones first.

Q: what is a logical method for modifying the query using pre_get_posts to show four specific posts before 'the rest'?

  • alternate method: use a do while loop – Vishwa May 10 at 9:54
  • Possible duplicate of WP_Query - Order results by meta value – leymannx May 10 at 10:00
  • Thanks, @leymannx. Order by meta value could work actually with the single caveat that I don't believe I'd be able to limit that ordering to first X posts with the value. That may not be a deal breaker though. – Kevin Nugent May 13 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.