Liquid, JavaScript, themes, sales channels
I am running Studio theme 4.0.0 and need to remove all pages from appearing in the store search results. Right now, pages appear in search results as a solid color card with a tag that says Page. I have located what I believe to be the code referring to pages in the main-search.liquid file but I am unsure how much of the code should be removed without causing any problems.
Ideally I would like to include only products in the search results.
I consulted the Storefront search FAQ pages but did not find it helpful: https://shopify.dev/themes/navigation-search/search#the-search-form
Thanks-
Check the object_type property on each result in the search.results array to see if it's a product.
https://shopify.dev/api/liquid/objects/search#search-results
If in a loop just do the check then continue to the next loop
{%- if result.object_type != "product" -%}{% continue %}{%-endif -%}
Thanks for that tidbit. That's at least part of the puzzle.
did you manage to get a solution? I'm facing the same issue
Hey @thebarebar no direct solutions to my post...
But I went back to research and tracked down the information that I was looking for on how to exclude page results in the storefront search results for Studio 4.0.0 theme.
I'll include a link here to the original post: Take a look at this thread from right here in the Shopify Community forum back in September of this year. Another shout out to @VrVa and @Cedcommerce for their combined efforts.
I'm running Studio 4.0.0 theme, and the original notes were for Dawn 6.0.2 so make sure you understand the differences. There are two parts to the solution for excluding page results from the storefront search results. You'll need to edit your theme code, in particular your "main-search.liquid" file and create a custom metafield. As VrVa points out, by using a custom metafield this will allow you to hide pages without having to edit code each time.
Cheers-
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023