Archived topic
Search results in different pages
5 replies · Started by Nacho on September 30, 2020
Hello,
I was just wondering if it would be possible to show in the search results page only the results from a category page.
So for example I´ve a category called blog which is the archive page for posts with the category called "blog" but I also have a category called "asesoria" and a page as well. So in the blog´s search box I just want the results page to show items from the "blog" category and if you make the search from the "asesoria" page, just show the results with the category of "asesoria".
I hope that´s possible.
Thanks a lot team :)
Hi there,
The search form would need to include the query parameter for the current category. It looks like you're using Elementor to create the form, so you would need to ask their support if thats possible.
Hello David,
How would you do in the page that does not use elementor?
Because in the blog page I´m not using it.
Thanks a lot.
You would create your own search form in a HTML Widget like so:
<form method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<input type="hidden" name="cat" id="cat" value="5" />
<input type="text" size="16" name="s" value="Search" />
<input type="submit" value="Go" />
</form>
You would change the value="5" to match the ID of the Blog category.
Hello David,
Great, let´s try it out.
Thanks a lot.
You're welcome