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 -%}
New Feature: Automatic free shipping discounts
Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com
Problem Solved? ✔Accept and Like solutions to help future merchants
Answers powered by coffee Buy Paul a ☕ Coffee for more answers or donate to eff.org
Defeat problems ,Learn To Ask Questions The Smart Way
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-
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023