I have had this code on my site before (and still have) to hide some pages from search: Solved: Re: How to remove specific pages from storefront search results - Shopify Community
But after I updated the theme last week to Refresh 8.0.0, it no longer works.
- Do somebody know how can make my metafields to work again? Or some other easy way to hide pages?
{%- for item in search.results -%}
{% assign lazy_load = false %}
{%- if forloop.index > 2 -%}
{%- assign lazy_load = true -%}
{%- endif -%}
{% unless item.metafields.custom.hide_from_storefront_search == 1 %}
- {%- case item.object_type -%}
{%- when 'product' -%}
{%- capture product_settings -%}{%- if section.settings.product_show_vendor -%}vendor,{%- endif -%}title,price{%- endcapture -%}
{% render 'card-product',
card_product: item,
media_aspect_ratio: section.settings.image_ratio,
show_secondary_image: section.settings.show_secondary_image,
show_vendor: section.settings.show_vendor,
show_rating: section.settings.show_rating,
lazy_load: lazy_load
%}
{%- when 'article' -%}
{% render 'article-card',
article: item,
show_image: true,
show_date: section.settings.article_show_date,
show_author: section.settings.article_show_author,
show_badge: true,
media_aspect_ratio: 1,
lazy_load: lazy_load
%}
{%- when 'page' -%}
###
{{ item.title | truncate: 50 | escape }}
{{ 'templates.search.page' | t }}
{%- endcase -%}
{% endunless -%}
{%- endfor -%}
And is it also possible to hide some specific collections from search?