Shopify themes, liquid, logos, and UX
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?
Solved! Go to the solution
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>
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>
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>
@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?
Hey @lcr1,
Well, that we can't do with HTML. We must use liquid or do some coding for that. 🙂
Hope you understand.
Thanks!
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024