Skip to main content
All CollectionsAdvanced Design
Keep The Current Search Term in The Search Bar
Keep The Current Search Term in The Search Bar
Marc McCall avatar
Written by Marc McCall
Updated over a week ago

When a user is viewing search results, they might want to search again by modifying their search term (EX:. If they've made a typo).
It would be easier for the user if the current search term is still in the search bar and can be edited or removed entirely if they're going to search for something different, rather than typing out the search again.

Add the script below to your Footer Block in Theme Options


if (('?query=') >= 0 ||'?querybrand=') >= 0) ) {

// Get search text

const searchText = function searchText() {

let search ='&').shift(),

regex1 = /[+]+/gm;

return search.replace(regex1, " ");


var searchString = $('#breadcrumb span').html();

searchString = searchString.replace(/\s\s+/g, ' ');

var searchQuery = searchString.substr(searchString.indexOf(" ") + 15);

searchQuery = searchQuery.replace(/"|'/g, '');


// Add the search results to search bar

const searchbar = document.querySelector('.header-full .widgetsearch input[type="text"]');

searchbar.value = searchQuery;



Did this answer your question?