I am writing a plugin for wordpress and I want to create my own search. I have tried to alter the wordpress search, but what I am doing is very specific with the SQL query. I am comparing lat and long coordinates and getting posts based on that.
I can display posts by using the standard wpdb query, but then I don’t get the other features like paging. I’d like to be able to use my SQL statement with the WP_Query function. If I’m right in thinking, I should then be able to use the paging and other features which come from the $posts global variable.
Is this right?? I’ve googled for hours but can’t find anything for plugins outside of using args to select categories etc. I simply need to send a complete SQL command – nothing else.
Many thanks….
You might not end up with the most optimal of SQL queries, but if you get an array of all the post IDs you want to use (by using your own SQL first), then using
WP_Queryalong with the argumentspost__inandposts_per_page, WordPress will handle everything for you (including SQL limits, pagination and so forth).