Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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 -%}
Contact paull.newton+shopifyforum@gmail.com for the solutions you need
Save time & money ,Ask Questions The Smart Way
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Thank Paul with a ☕ Coffee for more answers or donate to eff.org
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-
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024