Implement a custom sorting logic for search results on my site

Hi everyone,

I would like to implement a custom sorting logic for search results on my site. Specifically, I want the listings to appear in the following order:

  1. Featured listings should always appear at the top.

  2. Verified listings should come next (after the featured ones).

  3. Regular listings should appear at the bottom.

Is there any way to achieve this with HivePress? Perhaps a custom PHP snippet or guidance on how to modify the sorting logic would be helpful.

Thank you for your assistance!

Best regards,

Alessio

Hi,

We recommend using this hook: posts_orderby – Hook | Developer.WordPress.org. There you can check if it is hp_listing post type and search query or main query, and add sorting by hp_verified meta field to the sorting that is in the SQL query.

​I hope this is helpful to you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.