How can I modify the predictive search bar to show only articles?

Topic summary

Goal: modify Shopify’s predictive search so results show only articles/blog posts instead of suggestions, products, or pages.

Key inputs:

  • One reply explains predictive search (type-ahead results for queries, products, collections, and other content) and suggests configuring behavior via Shopify’s Search & Discovery app.
  • Another reply provides step-by-step instructions to edit Sections > predictive-search.liquid and replace it with a provided Liquid template. The template emphasizes pages and articles (and shows suggestions), but does not strictly limit results to articles only.

Latest status:

  • Original poster reports the code didn’t fully solve the requirement but was a helpful starting point.
  • A subsequent participant asks the OP to share their final solution for related UI updates.

Outcome:

  • No confirmed solution that restricts predictive search exclusively to articles was provided.
  • Discussion remains open with a request for the implemented approach.

Notes:

  • The provided code snippet is central to understanding the proposed implementation.
  • Predictive search = real-time, type-ahead suggestions within the storefront search bar.
Summarized with AI on January 12. AI used: gpt-5.

Hey Guys, I would like to know how to modiify the predictive search results by changing the suggestions, products and pages with articles or blog posts only. Or is it even possible?
Something like this,

But instead of suggestions, products and pages, articles will show. Thanks in advance.

1 Like

Hi @alicanteallan7 ,

This is Anthony from Beae Landing Page Builder, and I’m happy to assist you today.

While I acknowledge that this issue falls short of the desired outcome, I have an idea that I believe might be of help:

Predictive search provides suggested outcomes while you type, aiding customers in honing their searches without the need to navigate to a separate search results page. This enables them to swiftly explore your store by previewing leading outcomes related to suggested search queries, products, collections, and other content.

You have the ability to tailor the functioning of predictive search using Search & Discovery app

Best regards,

Anthony

Hi @alicanteallan7

Please follow the instructions below to achieve the said query.

  • From your Shopify admin dashboard, click on “Online Store” and then “Themes”.
  • Find the theme that you want to edit and click on “Actions” and then “Edit code”.
  • In the “Section” folder, click on “predictive-search.liquid” file.
  • Replace the whole code with the code below
{% comment %}theme-check-disable ImgLazyLoading{% endcomment %}
{%- if predictive_search.performed -%}
  {% assign first_column_results_size = predictive_search.resources.queries.size
    | plus: predictive_search.resources.collections.size
    | plus: predictive_search.resources.pages.size
    | plus: predictive_search.resources.articles.size
  %}
  
    {%- if first_column_results_size > 0 or predictive_search.resources.products.size > 0 -%}
      

    {%- endif -%}
    {%- if first_column_results_size > 0 -%}
      

    {%- endif -%}
    {%- if predictive_search.resources.queries.size > 0 -%}
      

        ## 
          {{- 'templates.search.suggestions' | t -}}
        
        
          {%- for query in predictive_search.resources.queries -%}
            - {{ query.styled_text }}
                  

                

              
            

          {%- endfor -%}
          {% comment %}
            {%- for collection in predictive_search.resources.collections -%}
              - {{ collection.title }}

                  

                
              
            {%- endfor -%}
          {% endcomment %}
        

      

    {%- endif -%}
    {%- if predictive_search.resources.articles.size > 0 or predictive_search.resources.pages.size > 0 -%}
      
        ## 
          {{- 'templates.search.pages' | t -}}
        
        
          {%- for page in predictive_search.resources.pages -%}
            - {{ page.title }}

                

              
            

          {%- endfor -%}
          {%- for article in predictive_search.resources.articles -%}
            - {{ article.title }}

                

              
            
          {%- endfor -%}
        

      

    {%- endif -%}
    {%- if first_column_results_size > 0 -%}
      

    {%- endif -%}
    {%- if predictive_search.resources.articles.size > 0 or predictive_search.resources.pages.size > 0 -%}
      
        {%- if predictive_search.resources.articles.size > 0 or predictive_search.resources.pages.size > 0 -%}
          

            ## 
              {{- 'templates.search.pages' | t -}}
            
            
              {%- for page in predictive_search.resources.pages -%}
                - {{ page.title }}

                    

                  
                

              {%- endfor -%}
              {%- for article in predictive_search.resources.articles -%}
                - {{ article.title }}

                    

                  
                
              {%- endfor -%}
            

          

        {%- endif -%}
      

    {%- endif -%}
    {%- if first_column_results_size > 0 -%}
      

    {%- endif -%}

    
      
    

    
      
    

  

  
    {% liquid
      assign total_results = predictive_search.resources.products.size | plus: first_column_results_size
      if total_results == 0
        echo 'templates.search.no_results' | t: terms: predictive_search.terms
      else
        echo 'templates.search.results_with_count' | t: count: total_results | append: ': '
        if predictive_search.resources.queries.size > 0
          assign count = predictive_search.resources.queries.size | plus: predictive_search.resources.collections.size
          echo 'templates.search.results_suggestions_with_count' | t: count: count | append: ', '
        endif
        if predictive_search.resources.pages.size > 0
          assign count = predictive_search.resources.pages.size | plus: predictive_search.resources.articles.size
          echo 'templates.search.results_pages_with_count' | t: count: count | append: ', '
        endif
      endif
    %}
  
{%- endif -%}
  • Save

Please don’t forget to Like and Mark Solution to the post that helped you. Thanks!

1 Like

Thanks for this, though It didn’t solve my problem but it gave me a headstart. Appreciate it.

Can you share your solution, also looking to make UI updates to the same section. Appreciate any insight