2017-04-17 132 views
0

我想從Shopify產品只顯示產品,但有數字顯示也是網頁和帖子這裏是我的搜索結果代碼:如何在shopify搜索結果中僅顯示產品?

<div class="product-list"> 
    {% if grid_results == false %} 
    {% for item in search.results %} 
    {% include 'search-result' %} 
    {% endfor %} 
    {% else %} 
    <div class="grid-uniform"> 
     {% for item in search.results %} 
     {% include 'search-result-grid' %} 
     {% endfor %} 
    </div> 
    {% endif %} 
    {% endif %} 
    </div> 

現在,我得到了下面的代碼:

{% if item.object_type == 'product' %} 

但是,在把這個代碼,所以我可以得到只有產品搜索任何文字。

回答

1

Shopify擁有絕佳的自助指南,適用於大部分內容。這裏有一個這樣的

Show only products in storefront search results

+0

你是對的,但我想這樣使用的代碼。 –

+0

如果在搜索結果的第2頁中發現,如果您使用代碼將其過濾出來,則有可能會顯示0結果。說了這兩個'include'語句之上的代碼'{%if item.object_type =='product'%}'。 – HymnZ