Solved

Can the search bar on Shopify be limited to blog posts only?

lcr1
Excursionist
18 0 31

Hi,

i added this code on a page: 

<form method="get" action="/search">
    <input type="text" name="q" />
    <input  type="submit" value="Search" />
</form>

But I want this search bar to only search for blog posts. How can I do this?

Accepted Solution (1)
dmwwebartisan
Shopify Partner
12280 2546 3694

This is an accepted solution.

Hey @lcr1,

Ahh, I thought you are working on the liquid file. I was not aware that you are putting this in the editor. In the editor, liquid code won't work.

So let's play with your code instead of liquid. Try the following code. This is your code. I just added a hidden input box there to pass the value article.

<form method="get" action="/search">
    <input type="hidden" name="type" value="article" />
    <input type="text" name="q" />
    <input  type="submit" value="Search" />
</form>

 

 

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
Check here PageFly App to customize your pages | #1 Product Filter & Search app on Shopify | The most powerful Shopify page builder app

View solution in original post

Replies 6 (6)

dmwwebartisan
Shopify Partner
12280 2546 3694

Hey @lcr1,

Try the following code.

<form action="/search" method="get" role="search">
    <input type="hidden" name="type" value="article" />
    <div class="input-group--underline">
      <input class="input-group__field" type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" aria-label="{{ 'general.search.placeholder' | t }}">
      <div class="input-group__btn">
        <button type="submit" class="btn btn--clear btn--square">
          {% include 'icon-search' %}
          <span class="icon__fallback-text">{{ 'general.search.submit' | t }}</span>
        </button>
      </div>
    </div>
  </form>
If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
Check here PageFly App to customize your pages | #1 Product Filter & Search app on Shopify | The most powerful Shopify page builder app
lcr1
Excursionist
18 0 31

@dmwwebartisan Hmm it’s not working. Or should I add it elsewhere? See photo.

2F4F73CC-8B0F-4681-987C-DF4D1DCD34B9.jpeg

dmwwebartisan
Shopify Partner
12280 2546 3694

This is an accepted solution.

Hey @lcr1,

Ahh, I thought you are working on the liquid file. I was not aware that you are putting this in the editor. In the editor, liquid code won't work.

So let's play with your code instead of liquid. Try the following code. This is your code. I just added a hidden input box there to pass the value article.

<form method="get" action="/search">
    <input type="hidden" name="type" value="article" />
    <input type="text" name="q" />
    <input  type="submit" value="Search" />
</form>

 

 

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
Check here PageFly App to customize your pages | #1 Product Filter & Search app on Shopify | The most powerful Shopify page builder app
lcr1
Excursionist
18 0 31

@dmwwebartisan Hehe, this worked perfect :))

Do you also know if it’s possible to do: no result then return and try again?
Or is that a bit more complex?

dmwwebartisan
Shopify Partner
12280 2546 3694

Hey @lcr1,

Well, that we can't do with HTML. We must use liquid or do some coding for that. 🙂

Hope you understand.

Thanks!

If helpful then please Like and Accept Solution | Email: dmw.webartisan@gmail.com |  Instagram: @dmw.webartisan
Check here PageFly App to customize your pages | #1 Product Filter & Search app on Shopify | The most powerful Shopify page builder app
lcr1
Excursionist
18 0 31

@dmwwebartisan I understand. But thank you for the solution 🙂