• SUMMARY: I want to create a front-end JQuery autocomplete functionality for a form field (in a child theme), and I want to generate the list of possible terms by accessing a custom table using WPDB.

    Details: I have a search form, in wcmc-searchform.php , whose action value is page-sr.php. Also, in functions.php I have a function that requires the script wcmcAJAX.php. wcmcAjax.php uses the WPDB object.

    To reduce clutter, the source code below is located at pastebin.com:

    wcmc-searchform.php: see http://pastebin.com/R0es7DtT

    page-sr.php: see http://pastebin.com/vgDhjybW

    wcmcAJAX.php: http://pastebin.com/3xewJzuj

    The form field of interest is the input element with name=”keyword”. On submit, the form works. It properly returns a list of custom posts from the database table. But the possible search terms are limited to the all the terms in this custom taxonomy. In other words, from a user’s point of view, they could search ‘soils’ and it would return nothing, even though ‘soil’ is a valid term.

    My initial thought was to mitigate this problem by use of autocomplete. In particular I want to use JQuery autocomplete. I have found many tutorials, and reviewed the codex, but I keep running into problems and getting confused.

    I have recently discovered a very basic tutorial for front-end ajax in wordpress : http://www.jackreichert.com/2013/03/24/using-ajax-in-wordpress-development-the-quickstart-guide/ . I am using that tutorial as a starting point, so that I can adapt it to my purposes. It doesn’t use Jquery autocomplete at all, but it was the only way I could make a working example of front-end ajax in WordPress.

    I am choosing NOT to include my source code that relates to the above project, because it looks exactly like the code provided on the tutorial. (except that I replaced get_template_directory_uri() with get_stylesheet_directory_uri() )

    MY REQUEST: Please provide information that could be helpful in my effort to create a JQuery Autocomplete form, that gets it’s list of possible terms to match from a custom WPDB query.

    Here are some posts that were somewhat helpful:

  • The topic ‘Jquery Autocomplete, front end, with WPDB’ is closed to new replies.