Adding Search Snippet to a regular page

ahmedjawwad
Tourist
3 0 0

Hi all, I am new to the Shopify, when someone searches my store for "salt lamps" only then my manually added "page" should kick in with the url /pages/salt-lamps and show search results for "salt lamps" on my manually created regular page. Is this possible? if yes then please guide me through how can I add this functionality to my online store without using any apps.

0 Likes

Hey,

The code below creates a search box. You probably wanna add it in page.liquid. For very specific custom coding you'll have to hire a developer to assist you.

1. In your Shopify Admin go to online store > themes > actions > edit code
2. Find page.liquid file and add this code:

<form method="get" action="/search">
    <input type="text" name="q" />
    <input  type="submit" value="Search" />
</form>


Let me know whether it works.

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Using a free theme? Improve it with copy/paste code snippets clicking here.
◦ Looking to hire an experienced developer? Same day response: ezfycode@gmail.com.
ahmedjawwad
Tourist
3 0 0

Thanks @diego_ezfy for your reply, I added this but this adds search form to the regular page. following is what I am looking for my store.

1- User searches for any string in any search form

2- checks if string is "salt lamps", if yes then redirect to /pages/salt-lamps and show result on that page, if string is not "salt lamps" then apply regular search.

By SEO perspective i am thinking.

Once again thanks a lot for your prompt reply, looking forward for a solution to this.

cheers

0 Likes

@ahmedjawwad 

Oh, I see.

This would require advanced Liquid/Javascript knowledge to be implemented, I'm afraid that unfortunately there is no simple copy-paste solution for this one otherwise I'd happily guide you through.

In case you're unfamiliar with these technologies you may want to hire a Shopify developer to assist you.

Kind regards, 
Diego

◦ Problem Solved? ✔️ Please click on Accept as Solution and like.
◦ Using a free theme? Improve it with copy/paste code snippets clicking here.
◦ Looking to hire an experienced developer? Same day response: ezfycode@gmail.com.
ahmedjawwad
Tourist
3 0 0

ok so now I have added custom jQuery code, that changes the form's action to /pages/salt-lamps in case of "salt lamps" and submits via jQuery. In my regular salt-lamps page i have a custom suffix page.custom-search.liquid

for the page.custom-search i have included a snippet custom-search and copied code from search.liquid but as 'snippet' doesnot implement the search, it shows Array 'search.results' is not paginateable

0 Likes