Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

To Search Specific Post Type

function philosophy_search_form($form)
{
   $home_dir = home_url('/');
   $label = __('Search for:', 'philosophy');
   $btn_label = __('Search', 'philosophy');
   $search_form = <<<FORM
   <form role="search" method="get" class="header__search-form" action="{$home_dir}">
      <label>
            <span class="hide-content">{$label}</span>
            <input type="search" class="search-field" placeholder="Type Keywords" value="" name="s" title="{$label}" autocomplete="off">
      </label>
      <input type="hidden" name="post_type" value="book">
      <input type="submit" class="search-submit" value="{$btn_label}">
   </form>
   FORM;

   return $search_form;
}
add_filter('get_search_form', 'philosophy_search_form');
 
PREVIOUS NEXT
Tagged: #To #Search #Specific #Post #Type
ADD COMMENT
Topic
Name
9+6 =