Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Best way to add a search function? WordPress

I have a page which has loads of resources in different categories. I want to add a search function to that page that only searches within the resources category and sub categories.

Answers (7)


Fahad Murtaza answers:

Try this

Fahad Murtaza comments:

google translate should help you understand easily.


Francisco Javier Carazo Gil answers:

Hi Steve,

Which kind of data are these categories, subcategories and resouces.

Do you use custom post type and custom taxonomies?


Agus Setiawan answers:

hi steve, hope this code will help you

<form method="get" id="search form" action="/">
<input type="text" value="" name="s" id="s" />
<input type="hidden" value="22" name="cat" id="scat" />


Michael Caputo answers:

You need to add a hidden field to your search form. It would look something like this:

<input type=”hidden” name=”cat” value=”31,7″/>

You see in the 'value' field there is 28, and 7 - change those numbers to the category ID of the categories you would like to include in your search.


Jatin Soni answers:

Place below code into the page template to search by category dropdown list.

<form class="searchcat" role="search" method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<div class="rowElem">
<input type="text" value="" name="s" id="s" tabindex="1" placeholder="search here..." /><?php wp_dropdown_categories( 'show_option_all=All Type' ); ?>
<input type="submit" id="searchsubmit" value="Search" tabindex="2" />


Nilesh shiragave answers:

Try following plugin

[[LINK href=""]]5sec category search[[/LINK]]


Arnav Joy answers:

check this link