# Custom Stop Words for Site Search

> Ignores filler words such as "can", "my" or "need" in multi-word searches, so "how can I reset my password" finds posts about resetting passwords.

- Type: PHP
- Runs: Run everywhere
- Category: [Search](https://wpide.com/library/category/search/)
- Tags: search, stopwords, relevance
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/search-custom-stop-words/

## Code

```php
// Extra words to ignore in multi-word searches, so "how can I reset my password" searches for "reset password".
$wpide_extra_stopwords = array( 'can', 'do', 'does', 'i', 'my', 'me', 'you', 'your', 'want', 'need', 'please', 'why', 'which', 'get' );
// Words WordPress ignores by default that matter on your site (for example 'who' for a band site).
$wpide_keep_words = array();

add_filter( 'wp_search_stopwords', function ( $stopwords ) use ( $wpide_extra_stopwords, $wpide_keep_words ) {
    $stopwords = array_merge( $stopwords, array_map( 'strtolower', $wpide_extra_stopwords ) );

    return array_values( array_diff( array_unique( $stopwords ), array_map( 'strtolower', $wpide_keep_words ) ) );
} );
```

## Notes

WordPress only drops stop words from searches with several words; list words that matter on your site under the keep list.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Custom Stop Words for Site Search" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
