title: Limiting Wordpress Search to specific blog category not working
body: <p>So I'm trying to create a search form on a blog page so that it only searches the posts with the category &quot;blog&quot;
  this is the search form code I'm using:</p>
  <pre><code>&lt;form  method=&quot;get&quot; action=&quot;&lt;?php echo esc_url( home_url( '/' ) ); ?&gt;&quot;&gt;
  
                     &lt;input type=&quot;hidden&quot;  name=&quot;cat&quot; id=&quot;blog&quot; value=&quot;7&quot; /&gt;
                     
                      &lt;input type=&quot;text&quot; value=&quot;&lt;?php echo get_search_query(); ?&gt;&quot; name=&quot;s&quot; /&gt;
                      &lt;input type=&quot;submit&quot; value=&quot;Search&quot; /&gt;
              &lt;/form&gt; 
  </code></pre>
  <p>This is the search.php code:</p>
  <pre><code>&lt;?php
  /**
   * The template for displaying search results pages
   *
   * @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
   *
   * @package Scrap
   */
  
  get_header();
  ?&gt;
  
      &lt;main id=&quot;primary&quot; class=&quot;site-main&quot;&gt;
  
          &lt;?php
  $s=get_search_query();
  $args = array(
                  's' =&gt;$s
              );
      // The Query
  $the_query = new WP_Query( $args );
  
  if ( $the_query-&gt;have_posts() ) {
          _e(&quot;&lt;h2 style='font-weight:bold;color:#000'&gt;Search Results for: &quot;.get_query_var('s').&quot;&lt;/h2&gt;&quot;);
          while ( $the_query-&gt;have_posts() ) {
             $the_query-&gt;the_post();
                   ?&gt;
                      &lt;li&gt;
                          &lt;a href=&quot;&lt;?php the_permalink(); ?&gt;&quot;&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                      &lt;/li&gt;
                   &lt;?php
          }
      }else{
  ?&gt;
          &lt;h2 style='font-weight:bold;color:#000'&gt;Nothing Found&lt;/h2&gt;
          &lt;div class=&quot;alert alert-info&quot;&gt;
            &lt;p&gt;Sorry, but nothing matched your search criteria. Please try again with some different keywords.&lt;/p&gt;
          &lt;/div&gt;
  &lt;?php } ?&gt;
  
      &lt;/main&gt;&lt;!-- #main --&gt;
  
  &lt;?php
  // get_sidebar();
  get_footer();
  </code></pre>
  <p>When a query is searched, the url loads like it's limited to the category: <a href="https://www.scraperapi.com/?cat=7&amp;s=proxies" rel="nofollow noreferrer">https://www.scraperapi.com/?cat=7&amp;s=proxies</a>
  But it still shows pages that are from outside of the category, and it doesn't load all of the blog posts that match the search query.
  The search form is live at <a href="https://www.scraperapi.com/blog/" rel="nofollow noreferrer">https://www.scraperapi.com/blog/</a> but it is display:hidden within a div called &quot;blog-search&quot; at the top.</p>
  <p>Thank you so much in advance for any help offered!!</p>