I'm using custom post types to display properties and have a custom price field assigned to each post. On the property page I want to display a list of four similarly priced properties, two less than or equal to the price of the current property and two greater than the current price. Ordering properties numerically by price is easy enough with wp_query, but how do I only display the closest values to the price of the current property?
Tell me more
×
WordPress Answers is a question and answer site for
WordPress developers and administrators. It's 100% free, no registration required.
|
One possibility is a direct SQL query similar to the one given here. But I'm not convinced that it would be much more efficient than 2 queries, all handled by WordPress: The is untested
|
|||||||||||
|
EditThanks for calling me out, it's the only way to get better. The updated query would look like this:
Thanks again, kaiser for making me do the right thing. The quickest thing to do is to create your own query using
Don't forget to change the values of |
|||||||
|