• Resolved kingjonats

    (@kingjonats)


    I was able to create dropdown when using the search button. However, is there a way to put a dropdown when creating a new post or ad? Similar drop as when searching?

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

    (@gwin)

    Hi, yes, you can convert the location in [adverts_add] to a dropdown similarly as the input in the search form

    
    add_filter( 'adverts_form_load', 'location_to_dropdown_add' );
    
     function location_to_dropdown_add( $form ) {
    
         if( $form['name'] != 'advert' ) {
             return $form;
         }
    
         foreach( $form["field"] as $key => $field ) {
             if( $field["name"] == "adverts_location" ) {
                 $field["type"] = "adverts_field_select";
                 $field["options"] = array(
                     array("value" => "London", "text" => "London"),
                     array("value" => "New York", "text" => "New York"),
                     // more options here
                 );
                 $form["field"][$key] = $field;
             }
         }
    
         return $form;
     }
    
    Thread Starter kingjonats

    (@kingjonats)

    It works! Thank you so much!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Location Dropdown when creating new ads’ is closed to new replies.