WP Site Search is powered by a Google Custom Search Engine (Google CSE). More specifically, the WP Site Search plugin automatically builds a Linked CSE that you can customize in a number of ways, even without a Google CSE account ID. This is because the Linked CSE consists of an XML file that contains search engine specifications. This XML file is produced by WP Site Search and served by your site via WordPress behind-the-scenes — which gives Google everything it needs to know about your custom search engine.
Customizing Google CSE via Shortcode Attributes
The [google_cse /]
Shortcode is placed into a WordPress Page that you designate as being the 'Search' Page for your site. When you install WP Site Search, this Page is automatically created for you and the [google_cse /]
Shortcode is automatically inserted into the content for this Page. To customize further, you can open the designated 'Search' Page in WordPress and add Shortcode Attributes as follows.
Shortcode Attributes
enableHistory="{bool}"
Set this to a true
or false
value. True indicates that back/forward functionality should be implemented via hash changes in the address bar as you navigate the search engine results and/or perform additional searches from the designated Search Page in WordPress. Setting it to false
turns this off.
[google_cse enableHistory="true" /]
queryParameterName="{var}"
Defaults to what you configured as the Query Variable in your WP Site Search options.
[google_cse queryParameterName="q" /]
gaQueryParameter="{var}"
This also defaults to what you configured as the Query Variable in your WP Site Search options.
[google_cse gaQueryParameter="q" /]
enableAutoComplete="{bool}"
Set this to a true
or false
value. True indicates that search box auto-complete (suggestions) should be enabled. Note that this takes time before it begins to work, because Google needs time to observe search behavior on your site so it can offer good suggestions.
[google_cse enableAutoComplete="true" /]
autoCompleteMatchType="{any|ordered|prefix}"
Please see Google CSE Attributes to learn more about this setting.
[google_cse autoCompleteMatchType="any" /]
autoCompleteMaxCompletions="{integer}"
Please see Google CSE Attributes to learn more about this setting.
[google_cse autoCompleteMaxCompletions="10" /]
defaultToRefinement="{tab}"
If you configured any Additional Tabs in your WP Site Search options, the title of a tab can be referenced here by converting the title to lowercase and replacing spaces with _
underscores. So for instance, if I have a Custom Search Tab with the title: KB Articles, I can set defaultToRefinement="kb_articles"
to make this the default tab when a new search is performed. Please see Google CSE Attributes to learn more about this setting.
[google_cse defaultToRefinement="kb_articles" /]
See also: Creating Custom Search Tabs
Additional Shortcode Attributes
For a full and complete list of all possible attributes, please see: Google CSE Attributes. Note: Any attribute described by the official Google CSE documentation is also a valid Shortcode Attribute.
[google_cse safeSearch="off" refinementStyle="link" linkTarget="_blank" /]