Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    If customer needs to search all locations then he should not select anything in the Location field when doing search.

    Thread Starter andriy14

    (@andriy14)

    But first city in list goes as default for search…

    add_filter( 'adverts_form_load', 'location_to_dropdown' );
    
     function location_to_dropdown( $form ) {
    
         if( $form['name'] != 'search' ) {
             return $form;
         }
    
         foreach( $form["field"] as $key => $field ) {
             if( $field["name"] == "location" ) {
                 $field["type"] = "adverts_field_select";
                 $field["options"] = array(
                    array("value" => "Киев", "text" => "Киев", "depth" => 0),
                    array("value" => "Александрия", "text" => "Александрия", "depth" => 0),
                    array("value" => "Бахмут (быв. Артёмовск)", "text" => "Бахмут (быв. Артёмовск)", "depth" => 0),
                 );
                 $form["field"][$key] = $field;
             }
         }
    
         return $form;
    }
    Plugin Author Greg Winiarski

    (@gwin)

    After

    $field["type"] = "adverts_field_select";

    add

    $field["empty_option"] = true;
    $field["empty_option_text"] = "All Locations";
    Thread Starter andriy14

    (@andriy14)

    It works fine with keyword and price search, thanks. But when choose some category to search ads in, it shows ‘Nothing here’. ‘All locations’ and ‘Category’ search functions conflict with each other(((

    Plugin Author Greg Winiarski

    (@gwin)

    What is your website URL?

    Thread Starter andriy14

    (@andriy14)

    Thread Starter andriy14

    (@andriy14)

    Hi Greg. Do you have any idea why ‘All locations’ and ‘Category’ search conflict? This function is so crucial

    Plugin Author Greg Winiarski

    (@gwin)

    I am not sure, i will check it later today on my site and update this thread.

    Plugin Author Greg Winiarski

    (@gwin)

    It seems to me that the search by category does not work on your site at all, regardless of settings in any other field.

    I assume you are using this https://github.com/simpliko/wpadverts-snippets/blob/master/search-by-category/search-by-category.php code snippet to implement search by category? If so then replace in this file all occurances of “advert_category” with for example “ad_category” (except line 62) and try searching again.

    Thread Starter andriy14

    (@andriy14)

    IT DOES WORK! THANK YOU SO MUCH! I’ve already reviewed and rated your plugin as 5 stars. Your support is awesome, that’s so rare.

    Plugin Author Greg Winiarski

    (@gwin)

    Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘'All locations' in search’ is closed to new replies.