Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like some help in creating a SQL statement that will query my WordPress database and return results based on search terms a user enters.

Basically it would be like this.

User term 1 (general string) User term 2 (zip code)

Return results if general string and/or zip code is found in either the title, description of the post, or the category of the post.

The hard part (for me) is getting the category part.

My guess is that it would be a simple SELECT statement with an INNER JOIN, but I my SQL skills are very limited.

Any help would be greatly appreciated. Edit post Delete post Reply with quote

share|improve this question

1 Answer 1

If you can formulate problematic part of your request as WP query you can run it and look at $wpdb->last_query to see generated SQL. This is usually easiest way to have a starting point and something to customize further.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.