Support » Fixing WordPress » WordPress search form by category not working?

  • Objective

    I am trying to create different search forms for two different landing pages. Thus, users who end up on landing page A will only be able to search for products with categories Man and Book. Users landing on page B will only be able to search for products with categories Beast and Funny.

    Here is my example setup in WooCommerce:

    What I have tried

    Based on this link, I have tried the following search function for page A.

    <form role="search" method="get" id="searchform" action="">
    <label for="s">Search for (Man and Book):</label>
    <input type="text" value="" name="s" id="s" />
    <input type="hidden" value="1" name="sentence" />
    <input type="hidden" value="product" name="post_type" />
    <input type="hidden" value="product_cat" name="man,book" />
    <input type="submit" id="searchsubmit" value="Search" />


    If I key in GetAllX into the search form, I expect to see GetAllX (Copy 2) only. Instead, I see GetAllX (Copy 2) and GetAllX.

    Also, when I key in test, I expect to see Test product 2 only. Instead, I see both Test product 2 and Test Product.


    1) Why is WordPress behaving like this? Can someone help me out with this, please?

    2) If there is an easier way to create search forms for different product categories based on landing pages, please do let me know.

  • You must be logged in to reply to this topic.