title: Wordpress search in custom post type without plugin
body: <p>i'm looking for a way to made search query only in custom post type and sometimes filter out category.</p>
  
  <p>I'm having code which builds search query but WordPress still returns posts and job-ads.</p>
  
  <pre><code>&lt;form method="get" id="searchform" action="&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;" role="search"&gt;
      &lt;label class="sr-only" for="s"&gt;&lt;?php esc_html_e( 'Search', 'understrap' ); ?&gt;&lt;/label&gt;
      &lt;div class="input-group"&gt;
        &lt;input class="field form-control" id="s" name="s" type="search"
          placeholder="&lt;?php esc_attr_e( 'Otsi &amp;hellip;', 'job-ads' ); ?&gt;" value="&lt;?php the_search_query(); ?&gt;"&gt;
        &lt;input type="hidden" name="post_type" value="job-ads"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="col-md-3"&gt;
      &lt;div class="input-group"&gt;
        &lt;?php wp_dropdown_categories( array(
            'show_option_all' =&gt; __('All job ads', 'job-ads'),
            'taxonomy' =&gt; 'tookategooria',
            'name' =&gt; 'category',
            'orderby' =&gt; 'name',
            'echo' =&gt; 1,
            'selected' =&gt; $cat,
            'hierarchical' =&gt; true,
            'class'   =&gt; 'cat-dropdown',
            'id'  =&gt; 'custom-cat-drop',
            'value_field' =&gt; 'term_id'
          ) ); ?&gt;  
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="col"&gt;
      &lt;span class="input-group-append"&gt;
        &lt;input class="submit btn" id="searchsubmit" name="submit" type="submit"
        value="&lt;?php esc_attr_e( 'Search', 'understrap' ); ?&gt;"&gt;
      &lt;/span&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>My custom post type is registered also without plugin, publicly querable and other settings have been checked. </p>
  
  <p>If i'm using my search string manually then it still returns all the posts</p>
  
  <p>String
  www.domain.com/?s=&amp;post_type=job-ads&amp;category=323</p>
  
  <p>It won't work without category either.</p>
  
  <p>For search results i'm using template which renders loop as in Worpress own theme search results. Basically all of the code is built on same basis.</p>
  
  <p>Any ideas how to force WordPress to display search results correctly?</p>