All things Shopify and commerce
I am looking for ways to modify my search form to search only for articles in a specific blog.
I have three blogs... Stories, Recipes, and Events.
I have a custom search form that is working to limit my search to articles only, I am looking for a way to augment the search form code to limit the form to only display articles from each specific blog.
Changing the value to "article" works great, I need to further limit this search to specific blogs.
I do not have a link that I can share.
I am not interested in any paid plugins or hiring anyone, just looking for advice/guidance.
If it is not possible I'm open to that as well.
<form action="{{ routes.search_url }}">
<input type="text"
placeholder="Search"
name="q"
value="{{ search.terms | escape }}"
/>
<input type="hidden" name="type" value="article" />
<input type="hidden" name="options[prefix]" value="last" />
<input type="submit" value="Search" />
</form>
To modify your search form to search only for articles in a specific blog, you can add another hidden input field to specify the blog. Here's an example of how you can modify your existing search form code:
<form action="{{ routes.search_url }}">
<input type="text"
placeholder="Search"
name="q"
value="{{ search.terms | escape }}"
/>
<input type="hidden" name="type" value="article" />
<input type="hidden" name="options[prefix]" value="last" />
<input type="hidden" name="blog" value="Stories" /> <!-- Specify the blog name here -->
<input type="submit" value="Search" />
</form>
In the example above, I've added a new hidden input field called "blog" and set its value to "Stories" as an example. You can replace "Stories" with the specific blog you want to limit the search to, such as "Recipes" or "Events".
@NomtechSolution Thanks for your reply and my apologies for not trying this sooner. Unfortunately, this isn't working for me. It is only returning articles but it is returning results from all three of my blogs 'recipes 'stories' and 'events.
Do you or anyone else have any additional thoughts on how to achieve this?
Just to clarify ... this code is returning articles ONLY but not only articles from STORIES
<input type="text"
placeholder="Search stories"
name="q"
value="{{ search.terms | escape }}"
/>
<input type="hidden" name="type" value="article" />
<input type="hidden" name="options[prefix]" value="last" />
<input type="hidden" name="blog" value="Stories" /> <!-- Specify the blog name here -->
<input type="image" name="submit" class="search-submit" src="{{ 'search.svg'| asset_url }}"/>
Did you ever figure this out?
No, I did not. As far as I know, Shopify won't accept that name/value in for the search form. I'm not sure why @NomtechSolution suggested it. The documentation does not have a "blog" as an option.
Same here
Hello, has the above case been open for a year or so since then, and have you found an effective solution?
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024