How can I restrict my Motion theme search results to products only?

Hello Dear,

I’m using the “Motion” theme, I don’t want users to search in the front end show the “Page,Article” results, just the product results.

How do I set it, I tried the online practice, but it does not work, this theme search page will appear two search boxes, when I use one of them to search, the Page result will not appear, but when I use the other search box to search, but the Page result appears.

Could you please help me to solve this problem? Thanks!

Hi @onforuleds ,

Please send me the code of header.liquid file, I will check and change it for you

Hello LitCommerce,

Thanks for your reply, the follow files is the header.liquid

Hi @onforuleds ,

Please change all code:

{%- liquid
  assign main_menu = linklists[section.settings.main_menu_link_list]

  assign logo_alignment = 'left'
  if section.settings.main_menu_alignment == 'center-left' or section.settings.main_menu_alignment == 'center-split' or section.settings.main_menu_alignment == 'center' or section.settings.main_menu_alignment == 'center-drawer'
    assign logo_alignment = 'center'
  endif

  assign template_name = template | replace: '.', ' ' | truncatewords: 2, '' | handle

  assign sticky_header = false
  assign overlay_header = false

  if section.settings.header_sticky
    assign sticky_header = true
  endif

  if template_name == 'index' and section.settings.sticky_index
    assign overlay_header = true
  endif
  if template_name contains 'collection' and collection.image and section.settings.sticky_collection
    assign overlay_header = true
  endif
-%}

{%- render 'drawer-menu', section: section, main_menu: main_menu, logo_alignment: logo_alignment -%}
{%- render 'cart-drawer' -%}

{%- style -%}
  .site-nav__link,
  .site-nav__dropdown-link {
    font-size: {{ settings.type_navigation_size }}px;
  }

  {%- if settings.type_navigation_size < 18 -%}
    .site-nav__link {
      padding-left: 8px;
      padding-right: 8px;
    }
  {%- endif -%}

  {%- if settings.color_header == settings.color_body_bg or settings.color_body_bg contains settings.color_header -%}
    .site-header {
      border-bottom: 1px solid;
      border-bottom-color: {{ settings.color_borders }};
    }
  {%- endif -%}
{%- endstyle -%}

  

    {%- if section.settings.show_announcement -%}
      {%- render 'announcement-bar', section: section -%}
    {%- endif -%}

    
  

{%- if template_name == 'index' and section.settings.sticky_index -%}
  {%- style -%}
    /* Offset first hero's text to make room for overlaid navigation */
    .shopify-section:first-child .hero__text-content.vertical-center {
      padding-top: 110px;
    }
    @media screen and (max-width: 768px) {
      .shopify-section:first-child .hero__text-content.vertical-center {
        padding-top: 70px;
      }
    }
  {%- endstyle -%}
{%- endif -%}

{% schema %}
{
  "name": "t:sections.header.name",
  "settings": [
    {
      "type": "header",
      "content": "t:sections.header.settings.header_logo"
    },
    {
      "type": "image_picker",
      "id": "logo",
      "label": "t:sections.header.settings.logo.label"
    },
    {
      "type": "image_picker",
      "id": "logo-inverted",
      "label": "t:sections.header.settings.logo-inverted.label",
      "info": "t:sections.header.settings.logo-inverted.info"
    },
    {
      "type": "range",
      "id": "desktop_logo_width",
      "label": "t:sections.header.settings.desktop_logo_width.label",
      "default": 200,
      "min": 100,
      "max": 400,
      "step": 10,
      "unit": "px"
    },
    {
      "type": "range",
      "id": "mobile_logo_width",
      "label": "t:sections.header.settings.mobile_logo_width.label",
      "default": 140,
      "min": 60,
      "max": 200,
      "step": 10,
      "unit": "px",
      "info": "t:sections.header.settings.mobile_logo_width.info"
    },
    {
      "type": "link_list",
      "id": "main_menu_link_list",
      "label": "t:sections.header.settings.main_menu_link_list.label",
      "default": "main-menu"
    },
    {
      "type": "select",
      "id": "main_menu_alignment",
      "label": "t:sections.header.settings.main_menu_alignment.label",
      "default": "left-center",
      "options": [
        {
          "value": "left",
          "label": "t:sections.header.settings.main_menu_alignment.options.left.label"
        },
        {
          "value": "left-center",
          "label": "t:sections.header.settings.main_menu_alignment.options.left-center.label"
        },
        {
          "value": "left-drawer",
          "label": "t:sections.header.settings.main_menu_alignment.options.left-drawer.label"
        },
        {
          "value": "center-left",
          "label": "t:sections.header.settings.main_menu_alignment.options.center-left.label"
        },
        {
          "value": "center-split",
          "label": "t:sections.header.settings.main_menu_alignment.options.center-split.label"
        },
        {
          "value": "center",
          "label": "t:sections.header.settings.main_menu_alignment.options.center.label"
        },
        {
          "value": "center-drawer",
          "label": "t:sections.header.settings.main_menu_alignment.options.center-drawer.label"
        }
      ]
    },
    {
      "type": "checkbox",
      "id": "header_sticky",
      "label": "t:sections.header.settings.header_sticky.label",
      "default": true
    },
    {
      "type": "checkbox",
      "id": "sticky_index",
      "label": "t:sections.header.settings.sticky_index.label",
      "default": false
    },
    {
      "type": "checkbox",
      "id": "sticky_collection",
      "label": "t:sections.header.settings.sticky_collection.label",
      "info": "t:sections.header.settings.sticky_collection.info",
      "default": false
    },
    {
      "type": "header",
      "content": "t:sections.header.settings.header_announcement_bar"
    },
    {
      "type": "checkbox",
      "id": "show_announcement",
      "label": "t:sections.header.settings.show_announcement.label"
    },
    {
      "type": "text",
      "id": "announcement_text",
      "label": "t:sections.header.settings.announcement_text.label",
      "default": "Free shipping and returns",
      "info": "t:sections.header.settings.announcement_text.info"
    },
    {
      "type": "url",
      "id": "announcement_link",
      "label": "t:sections.header.settings.announcement_link.label"
    },
    {
      "type": "checkbox",
      "id": "announcement_closable",
      "label": "t:sections.header.settings.announcement_closable.label"
    }
  ],
  "blocks": [
    {
      "type": "megamenu",
      "name": "t:sections.header.blocks.mega_menu.name",
      "settings": [
        {
          "type": "text",
          "id": "menu_item",
          "label": "t:sections.header.blocks.mega_menu.settings.menu_item.label",
          "info": "t:sections.header.blocks.mega_menu.settings.menu_item.info"
        },
        {
          "type": "header",
          "content": "t:sections.header.blocks.mega_menu.settings.header_promotion_1"
        },
        {
          "type": "image_picker",
          "id": "promo_image_1",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_image_1.label"
        },
        {
          "type": "text",
          "id": "promo_heading_1",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_heading_1.label"
        },
        {
          "type": "text",
          "id": "promo_text_1",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_text_1.label"
        },
        {
          "type": "url",
          "id": "promo_url_1",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_url_1.label"
        },
        {
          "type": "header",
          "content": "t:sections.header.blocks.mega_menu.settings.header_promotion_2"
        },
        {
          "type": "image_picker",
          "id": "promo_image_2",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_image_2.label"
        },
        {
          "type": "text",
          "id": "promo_heading_2",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_heading_2.label"
        },
        {
          "type": "text",
          "id": "promo_text_2",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_text_2.label"
        },
        {
          "type": "url",
          "id": "promo_url_2",
          "label": "t:sections.header.blocks.mega_menu.settings.promo_url_2.label"
        }
      ]
    }
  ],
  "default": {
    "settings": {}
  }
}
{% endschema %}

Hope it helps!

1 Like

Thanks LitCommerce,

I see you add this line" ", thank you very much!

1 Like