JQuery UI Autocomplete WordPress

I want to add autocompletion in a nickname search bar. I do not understand why it does not work. My code is correct ?

In my file liste.php

 global $wpdb;
    $name = $_POST['code_postal'];
    $sql = $wpdb->get_results("SELECT * FROM membres WHERE pseudo LIKE '$name%' ");

    $titles = array();
    foreach($sql as $key=> $value){
        echo $value->pseudo;

    echo json_encode($titles); //encode into JSON format and output

In my global.js

    source: function(name, response) {
            type: 'POST',
            dataType: 'json',
            url: 'wp-content/themes/ARLIANE/liste.php',
            data: 'action=get_listing_names&name='+name,
            success: function(data) {

In my index.php

  <input type="text" name="term" id="recherche"/>

Read more here: JQuery UI Autocomplete WordPress

Leave a Reply

Your email address will not be published. Required fields are marked *