Search Widget’s settings

You can adjust Search Widget’s functionality with a global JavaScript variable called “addsearch_settings”. The variable must be defined above the script tag loading AddSearch JavaScript snippet.

<!-- AddSearch settings -->
window.addsearch_settings = {
  default_sortby: 'date'

<!-- This script must be below addsearch_settings -->
<script src=""></script>


Currently addsearch_settings supports following settings:

relevance (default)
Default order of results
ga_tracking_idUA-xxxxxx-xGoogle Analytics tracking ID. Needed if Global site tag (gtag) in use
(e.g. "Search..")
Placeholder text to show in the search field
link_target_blank, _self, _top, _parentWindow or a frame where the clicked results link should open. E.g. _blank to open links in a new tab.
false (default)
Display the publishing date of search results instead of category
date_format_functionJavaScript functionCustom JavaScript function to format publishing dates in search results. The function is called with Date object as a parameter

Available JavaScript functions

Change the order of search results

To change the sort of search results, call the following function:


An example of the implementation:

function changeSort(event, sort) {
  // Prevent Widget from closing
  (event || window.event).stopPropagation();

Sort by:
<button onclick="changeSort(event, 'relevance');">Relevance</button>
<button onclick="changeSort(event, 'date');">Date</button>