Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 7

How to add a Search Block to the header?



  • Answers 58
  • Created
  • Last Reply

Top Posters For This Question

Recommended Posts

  • 0

How would i go about making this work in the BEDFORD template?I've tried to change the code and finding the right ting to input - but nothing seems to work.Has it changed in Squarespace7?

Any help would be greatly appreaciated :)

Link to comment
  • 0

Did this make the search bar on your site the way it is now? When I followed silva's instructions and added your tweak, I get the word SEARCH in my navigation bar instead and when you click on it, it sends you to the search page. www.walaowehh.com

Link to comment
  • 0

If anyone is interested in getting this to work on the Galapagos template (and any other template if adjustments are made):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  /* The code here replaces the search link in the navigation bar (which is required) */
  /* with the search block which was placed initially in the footer (also required) */
  $(".nav-container > ul.nav-list > li:nth-last-child(1) a").replaceWith($(".search-block"));

This should be injected at Settings > Advanced > Code Injection > Footer (it needs to run after the Search Block you placed in the footer has been created or else it will not work).

If you use another template that doesn't allow search blocks in the header, this should still work, you simply need to inspect the code on your actual webpage (right click > inspect) and search for the class naming conventions your template uses for its <nav> tag and make the necessary changes to the code above.  The Galapagos class naming for the navigation bar is .nav-container which has an unordered list (ul) with class name of nav-list which contains list items (li) so you would change those names (add/remove if needed) accordingly to what you find.

Link to comment
  • 0

For the Marquee template this is the naming convention that works currently:

$("#desktopNav > .main-nav > .nav-wrapper > ul.cf > li:nth-last-child(1) a").replaceWith($(".search-block"));

$("#desktopNav > .main-nav > .nav-wrapper > ul.cf > li:nth-last-child(1) a").replaceWith($(".search-block"));


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...