Title: Search with Wp Query
Last modified: February 18, 2021

---

# Search with Wp Query

 *  [leonleles](https://wordpress.org/support/users/leonleles/)
 * (@leonleles)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/search-with-wp-query/)
 * Take each word in a sentence and do the conditional search with OR and bring 
   results that contain any of those words in the post. I’m using the wp query `
   s` parameter.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/search-with-wp-query/#post-14070931)
 * What is the question? This feature is part of core.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/search-with-wp-query/#post-14076066)
 * You want OR logic applied to each word instead of the default AND logic, right?
   You could use the “posts_request” filter to alter the actual SQL used. Seek out
   the appropriate AND and change it to OR. Easier said than done though. It won’t
   do to change all occurrences of AND. The challenge is in changing the right ones.
 * I’d be inclined to compose my own WHERE clause in it’s entirety through the “
   posts_where” filter. Callbacks are passed the entire WP_Query object, from which
   the “s” query var can be used to compose your own WHERE clause.
 * There are various advanced search plugins. I’d expect at least a few would apply
   the OR logic you want without needing to custom code a solution.
 *  [Joy](https://wordpress.org/support/users/joyously/)
 * (@joyously)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/search-with-wp-query/#post-14076375)
 * When I read the code here: [https://developer.wordpress.org/reference/classes/wp_query/parse_search/](https://developer.wordpress.org/reference/classes/wp_query/parse_search/)
   
   it looks like the default is `OR`. And when I use the search I usually want it
   to be `AND`.
 * Edit: It is `OR` between content, title, excerpt.
    But if I put more words, I
   don’t want more matches, I want fewer matches (use `AND` between words).
    -  This reply was modified 5 years, 2 months ago by [Joy](https://wordpress.org/support/users/joyously/).
      Reason: clarify

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Search with Wp Query’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [Joy](https://wordpress.org/support/users/joyously/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/search-with-wp-query/#post-14076375)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
