How to get query string on search page in shopify?

Member

by rollin , in category: PHP CMS , a month ago

How to get query string on search page in shopify?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by dalton_moen , a month ago

@rollin 

You can access the query string parameter on a search page in Shopify using Liquid code. The query string parameter is typically stored in the q parameter in the URL.


To access the query string parameter in Shopify, you can use the {{ query }} liquid object. For example, if you want to display the search term entered by the user on the search page, you can use the following code:

1
<p>Search results for: '{{ query }}'</p>


This code will display the search term entered by the user in the search results page. You can use the {{ query }} object in your liquid template to access the query string parameter and customize your search page accordingly.