• Resolved Nishant Patel

    (@nishantpatel121)


    As we can add listing and manage Listing ,but would like to add predefined Locations when user adds it to listing. and then Listing page will get filtered by Location Dropdown

    The page I need help with: [log in to see the link]

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

    (@gwin)

    Hi,

    you can convert the location input (in both Publish and Search forms) to a dropdown by adding the code below in your theme functions.php file

    add_filter( "adverts_form_load", "adverts_add_location_to_dropdown" );
    function adverts_add_location_to_dropdown( $form ) {
      if( $form['name'] == "advert" ) {
        $field_name = "adverts_location";
      } else if( $form['name'] == "search" ) {
        $field_name = "location";
      } else {
        return $form;
      }
      foreach( $form["field"] as $key => $field ) {
        if( $field["name"] == $field_name ) {
            $form["field"][$key]["type"] = "adverts_field_select";
            $form["field"][$key]["empty_option"] = true;
            $form["field"][$key]["options"] = array(
                array( "value" => "London", "text" => "London" ),
                array( "value" => "New York", "text" => "New York" ),
                /// more options here ...
            );
        }
      }
      return $form;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Add Predefined Location City and Dropdown’ is closed to new replies.