I have 3 to 4 categories on my website. I am using WordPress search but when I am searching my category then I am getting

Nothing Found

also, I tried to search the subcategory then also I am getting the same message.

Would you help me out with this issue?


 <section id="primary" class="content-area mainSearch">
    <main id="main" class="site-main">
      <div class="equalPadding">
        <div class="cp-seeWrapper">
    <?php if ( have_posts() ) : 
          get_search_form();//search form
          <div class="resultCount"><?php
          global $wp_query;
          echo $wp_query->found_posts.' RESULTS';
         <div class="row">

       while (have_posts()){the_post();?>
        //displaying result here

       <?php } ?>

    else :
      get_template_part( 'template-parts/content', 'none' );

    </main><!-- #main -->
  </section><!-- #primary -->
  • WordPress doesn’t search categories. This is the normal behaviour. – Jacob Peattie Nov 20 '19 at 10:43
  • Is there any way? Because I have categories which are, tech, Accessories, feature, and home. I tried to search tech and I am getting Nothing found. – Naren Verma Nov 20 '19 at 10:51
  • At least it should be dislay the related product to the category while searching – Naren Verma Nov 20 '19 at 10:52
  • You could use the code from this answer: wordpress.stackexchange.com/questions/84549/… You can use get_terms function in general to fetch terms of a taxonomy in your case terms of category. Then in the get_terms() function's arguments you can pass the 'name__like' which will fetch terms with name like the one you pass. To pass the search query on the argument you can use the the_search_query() function. Hope it will help you. Sorry I am answering from my mobile. – giannisrig Nov 20 '19 at 11:02
  • Where should I add that code? – Naren Verma Nov 20 '19 at 11:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.