Documentation

View the installation guide, browse the Knowledge Base, find out about SearchWP's many hooks, get support

Available since: 1.0.10

searchwp_common_words

View Parameters »

Note: Use of this hook will require a manual reindex

By default, SearchWP excludes a list of words it considers to be too common to be useful in searches. These terms are sometimes called stop words, and by excluding them SearchWP is able to reduce the overall size of the search index without compromising the quality of the index and improving performance.

Example: To remove a select number of default common words, add something like the following to your active theme’s functions.php:

<?php
function my_searchwp_common_words( $terms ) {
// we DO NOT want to ignore 'first' so remove it from the list of common words
$words_to_keep = array( 'first' );
$terms = array_diff( $terms, $words_to_keep );
return $terms;
}
add_filter( 'searchwp_common_words', 'my_searchwp_common_words' );
view raw functions.php hosted with ❤ by GitHub

Example: To add your own common/stop words, add the following to your active theme’s functions.php:

<?php
function my_searchwp_common_words( $terms ) {
// add 'lorem', 'ipsum', and 'dolor' to SearchWP's default terms
$terms[] = 'lorem';
$terms[] = 'ipsum';
$terms[] = 'dolor';
return $terms;
}
add_filter( 'searchwp_common_words', 'my_searchwp_common_words' );
view raw gistfile1.php hosted with ❤ by GitHub

Example: To completely replace the default common words with your own, add the following to your active theme’s functions.php:

<?php
function my_searchwp_common_words( $terms ) {
// replace the default SearchWP default common words with 'lorem', 'ipsum', and 'dolor' ONLY
$terms = array( 'lorem', 'ipsum', 'dolor' );
return $terms;
}
add_filter( 'searchwp_common_words', 'my_searchwp_common_words' );
view raw gistfile1.php hosted with ❤ by GitHub

Example: To disable this feature entirely, return an empty array of common words and SearchWP will exclude nothing. You can do that by adding this snippet to your theme’s functions.php:

<?php
function my_searchwp_common_words( $terms ) {
// do not exclude any words from the index
return array();
}
add_filter( 'searchwp_common_words', 'my_searchwp_common_words' );
view raw functions.php hosted with ❤ by GitHub

Here is the list of default common words (stopwords) that ship with SearchWP:

<?php
// this can be completely customized https://searchwp.com/docs/hooks/searchwp_common_words/
array( "a", "able", "above", "across", "after", "afterwards", "again", "against", "ago", "all",
"almost", "alone", "along", "already", "also", "although", "always", "am", "among", "amongst", "amoungst",
"amount", "an", "and", "another", "any", "anyhow", "anyone", "anything", "anyway", "anywhere", "are", "aren't",
"around", "as", "at", "back", "be", "became", "because", "become", "becomes", "becoming", "been", "before",
"beforehand", "behind", "being", "below", "beside", "besides", "between", "beyond", "both", "bottom", "but",
"by", "call", "can", "can't", "cannot", "cant", "co", "con", "could", "couldn't", "couldnt", "de", "did", "do",
"does", "don't", "done", "dont", "down", "due", "during", "each", "eg", "eight", "either", "eleven", "else",
"elsewhere", "empty", "enough", "etc", "etc.", "even", "ever", "every", "everyone", "everything", "everywhere",
"except", "few", "fifteen", "fify", "fill", "find", "fire", "first", "five", "for", "former", "formerly",
"forty", "found", "four", "from", "front", "full", "further", "get", "give", "go", "got", "had", "has",
"hasn't", "hasnt", "have", "he", "hence", "her", "here", "hereafter", "hereby", "herein", "hereupon", "hers",
"herself", "him", "himself", "his", "how", "however", "hundred", "i", "i.e.", "ie", "if", "in", "inc", "inc.",
"indeed", "into", "is", "isn't", "it", "it's", "its", "itself", "just", "keep", "last", "latter", "latterly",
"least", "less", "let", "like", "likely", "ltd", "ltd.", "made", "many", "may", "maybe", "me", "meanwhile",
"might", "mill", "mine", "more", "moreover", "most", "mostly", "move", "much", "must", "my", "myself", "name",
"namely", "neither", "never", "nevertheless", "new", "news", "next", "nine", "no", "no-one", "nobody", "none",
"noone", "nor", "not", "nothing", "now", "nowhere", "of", "off", "often", "old", "on", "once", "one", "only",
"onto", "or", "other", "others", "otherwise", "our", "ours", "ourselves", "out", "over", "own", "per",
"perhaps", "please", "put", "rather", "re", "said", "same", "say", "says", "see", "seem", "seemed", "seeming",
"seems", "serious", "several", "she", "she's", "shes", "should", "show", "side", "since", "six", "sixty",
"small", "so", "some", "somehow", "someone", "something", "sometime", "sometimes", "somewhere", "still", "such",
"take", "ten", "than", "thank", "that", "the", "their", "theirs", "them", "themselves", "then", "thence",
"there", "thereafter", "thereby", "therefore", "therein", "thereupon", "these", "they", "they're", "theyre",
"third", "this", "those", "though", "three", "through", "throughout", "thru", "thus", "time", "times", "tis",
"to", "together", "too", "top", "toward", "towards", "true", "twas", "twelve", "twenty", "two", "un", "under",
"until", "up", "upon", "us", "use", "users", "very", "via", "want", "wants", "was", "way", "we", "web", "well",
"were", "what", "whatever", "when", "whence", "whenever", "where", "whereafter", "whereas", "whereby",
"wherein", "whereupon", "wherever", "whether", "which", "while", "whither", "who", "whoever", "whole", "whom",
"whose", "why", "will", "with", "within", "without", "would", "yes", "yet", "you", "your", "yours", "yourself",
"yourselves" );
view raw gistfile1.php hosted with ❤ by GitHub

 

Parameters

Parameter Type Description
$terms Array

The default terms SearchWP considers to be common/stop words

Fix Search on Your Site. No Coding Required!

Now you can utilize all of the content that's gone unrecognized by native WordPress search instantly with SearchWP

Get SearchWP