UPDATE: 06/07/21 - I managed to reach out to the Dev who found the answer, in case anyone else even has something similar. See answer in responses below.

We had our site built by a contractor. That contractor is no longer in business and can't help.

Our web site is www.summerfresh.com and uses a modified version of the twentyseventeen theme.

The developer created a custom search. When clicking on the spy glass search icon on the front page, you are presented with a search box, and after entering your search term you must click on one of three options: 1. search products; 2. search recipes; 3. search blog. The search function is supposed to search the entire site for your term, limited only by which of those three options you choose, but in reality it only works that way from the front page, and the blog page.

I've tried googling this issue, but I think it might be pretty unique because of the way the dev created the custom search to search within specific categories. Some of the potential solutions I've seen suggested making sure the searchform.php is searching all of home_url each time, and I've tried different variations of this, but it did not work. I think it might have something to do with the search "categories" the dev put in to the search box.

Ideally I would like it to just search for a term from the entire site, and perhaps even do away with the Product/Recipe/Blog choices from the search box, but I've had trouble finding something that will show me how to replace what the dev has properly with a default site wide search.

The issue in practice

When searching any term from the front page (a static page) or the "Fresh News" page (the wordpress posts page) the search function works correctly. When searching again from the search results page, the search works correctly. In these cases it seems to be correctly searching the entire site.

When searching from any second-level page (like /products/ or /recipes/ or /contact/) the results is "That page cannot be found".

When searching for something in a third-level recipes section (like /recipe-categories/dinner/) for a search term that would be found in that section, the search function returns results for that section but not results for that term that might be found elsewhere in one of the other /recipe-categories/ sections (or elsewhere on the site).

When searching for something in a third-level recipes section (like /recipe-categories/breakfast/) for a search term that would not be found in that section, but would be found elsewhere in one of the other /recipe-categories/ sections (or elsewhere on the site), the result is "Nothing Found".

When searching from an individual recipe page (like /recipe/loaded-baba-ghanouj-and-halloumi-flatbreads/) for a term that would or would not appear on that page, the result is "That page cannot be found".

To test this I tried searching for the term "chicken" with the "search recipes for" drop down option from each page type listed above to see what I would get.

The current searchform.php looks like this:

    <?php $unique_id = esc_attr( uniqid( 'search-form-' ) ); ?>
<form role="search" method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ) ?>">
    <label for="<?php echo $unique_id; ?>">
        <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label', 'twentyseventeen' ); ?></span>
    <input type="search" id="<?php echo $unique_id; ?>" class="search-field" placeholder="<?php echo esc_attr_x( 'Search &hellip;', 'placeholder', 'twentyseventeen' ); ?>" value="<?php echo get_search_query(); ?>" name="s" />
    <button type="submit" class="search-submit"><?php echo twentyseventeen_get_svg( array( 'icon' => 'search' ) ); ?><span class="screen-reader-text"><?php echo _x( 'Search', 'submit button', 'twentyseventeen' ); ?></span></button>

The search box is in the header.php like this:

 <div class="search-bar d-flex justify-content-center hidden-md-down">
                <div class="search-overlay"></div>
                <div class="search-close"><i class="fa fa-times fa-2x" aria-hidden="true"></i></div>
                <div class="row align-self-center">
                    <div class="col-sm-12">
                              <div class="form-group m-0">
                                <input type="text" class="form-control" id="search-input" placeholder="<?php echo __('Type your search and choose from the categories below.');?>" tabIndex="1">
                                <div class="dropdown-menu">
                                       <a href="#" data-href="?lang=<?php echo ICL_LANGUAGE_CODE;?>&post_type=product&s=" class="dropdown-item" tabIndex="2"><?php echo __('Search Products for'); ?> <span class="suggest-it"></span></a>
                                       <a href="#" data-href="?lang=<?php echo ICL_LANGUAGE_CODE;?>&post_type=recipe&s=" class="dropdown-item" tabIndex="3"><?php echo __('Search Recipes for'); ?><span class="suggest-it"></span></a>
                                       <a href="#" data-href="?lang=<?php echo ICL_LANGUAGE_CODE;?>&post_type=post&s=" class="dropdown-item" tabIndex="4"><?php echo __('Search Blog for'); ?><span class="suggest-it"></span></a>

Any advice you can give is greatly appreciated.

  • There must be some script too that takes the data-href from the dropdown menu and applies it to the search form post URL too? Maybe the problem is there. What do the search URLs generated look like, that work and don't work?
    – Rup
    May 20, 2021 at 12:38
  • (and even if your dev has gone out of business hopefully they'll still answer email or the phone for a quick question? or can recommend someone to take over the work?)
    – Rup
    May 20, 2021 at 12:39
  • Thank you for helping me. When searching from the front page, the resulting URL looks like this: "summerfresh.com/?post_type=recipe&s=chicken" When searching from one of the sub-pages that is a different category, the resulting URL is "summerfresh.com/products/hummus/?post_type=recipe&s=chicken" When searching from a sub-page that is unrelated to the search type the URL is this: "summerfresh.com/contact/?post_type=recipe&s=chicken" May 21, 2021 at 13:43
  • The solution (from the Dev) was to add a "/" before the first "?" in the code below for each of the three drop down search options. <a href="#" data-href="?lang=<?php echo ICL_LANGUAGE_CODE;?> Jun 7, 2021 at 17:22

1 Answer 1


The solution (from the Dev) was to add a "/" before the first "?" in the code below for each of the three drop down search options. <a href="#" data-href="?lang=

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.