Does anyone know if it is possible to hide items from the search results page (eg. I have 3 coke products in my catalog, but I only want 2 specific ones to display in the search results when page I search for “coke”), but not hide them from the search bar? I know the metafield “seo.hidden” can achieve this, but this method hides it from both the search results page AND the search bar.
Any ideas?
Hello @DannyMerc
Shopify doesn’t offer a native switch to show a product in the search bar but hide it from the search results page. The simplest workaround is to flag those products (via a tag or a custom metafield like hide_in_search) and then filter them out in your search results template only—your predictive search in the header will still pull from Shopify’s suggestion API and include them.
In your templates/search.liquid (or wherever you loop through search.results), wrap your product output in an if check. For example, if you’re using a tag called hide-from-search:
{% for item in search.results %}
{% if item.object_type == ‘product’ and item.tags contains ‘hide-from-search’ %}
{% continue %}
{% endif %}
{%- comment -%}
render your product card here
{%- endcomment -%}
{% endfor %}
Or you can reject them up front:{% assign visible_results = search.results | reject: “tags”, “hide-from-search” %}
{% for item in visible_results %}
{%- comment -%}
render your product card here
{%- endcomment -%}
{% endfor %}
This way, you only remove flagged products from the actual search results page. Your theme’s built-in predictive search/suggestions (the dropdown when someone types in the header) will remain unchanged and still surface those products.