vendredi 27 mai 2016

Convert dropdown into autocomplete search box in wordpress categories

The following code displays a list of all locations in a dropdown in my wordpress website. How can i change it into autocomplete search box, where it predicts users input on typing a minimum of 3 characters.

 <?php if( $has_location && $can_search_by_location ) : ?>
    <!-- Location field -->
    <div class="form-group">
        <label><?php _e( 'Location', 'advanced-classifieds-and-directory-pro' ); ?></label>
        <?php 
            wp_dropdown_categories( array(
                'show_option_none' => '-- '.__( 'Select a location', 'advanced-classifieds-and-directory-pro' ).' --',
                'taxonomy'         => 'acadp_locations',
                'name'             => 'loc',
                'id'               => 'acadp-location-search-'.$this->id,
                'class'            => 'form-control',
                'orderby'          => 'name',
                'selected'         => isset( $_GET['loc'] ) ? (int) $_GET['loc'] : -1,
                'hierarchical'     => true,
                'depth'            => 10,
                'show_count'       => false,
                'hide_empty'       => false,
            ) );
        ?>
    </div>
 <?php endif; ?>



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire