• Resolved marvink29

    (@marvink29)


    Hi Greg, first of all thank you for your amazing plugin I love it, however I have an issue concerning the locations search.
    I would like to display it with a drop-down list but I couldn’t figure out how to edit the code in the file list.php

    I guess I have to change something in the following lines but I don’t know what or how.

    <div class="advert-input <?php esc_attr_e( 'advert-input-type-' . $field['meta']['search_type'] ) ?>">
    
                    <?php call_user_func( adverts_field_get_renderer($field), $field) ?>
    
                </div>

    I don’t have an extended knowledge in PHP so I hope you will be able to help me.

    https://wordpress.org/plugins/wpadverts/

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

    (@gwin)

    Hi, you would need to add following code in your theme functions.php file

    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" => "London", "text" => "London"),
                     array("value" => "New York", "text" => "New York"),
                     // more options here
                 );
                 $form["field"][$key] = $field;
             }
         }
    
         return $form;
     }

    this will replace default location text field with dropdown with predefined options.

    Thread Starter marvink29

    (@marvink29)

    Hi thank you very much, it works well.

    I don’t know if that’s possible but if it is I would like to know how to resize the dropdown to have the two fields with a similar appearance.

    Thanks in advance.

    Plugin Author Greg Winiarski

    (@gwin)

    Please try adding following code to your theme CSS file, this should set proper select width.

    .advert-input select {
        width: 100%;
    }
    Thread Starter marvink29

    (@marvink29)

    That’s perfect, thanks a lot, a great plugin and a great support I will recommend it !

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

The topic ‘Drop-Down List for locations search’ is closed to new replies.