jQuery autocomplete in Wordpress

admin

Administrator
Staff member
I'm trying to set up Autocomplete on a wordpress site using PHP script. But nothing is showing up currently in my code. I understand that general idea is to have a jQuery function that would use PHP script that would pull up MySQL data(suggest.php) in this case. Also if I were to put

Code:
<script>
  $( function() {
    $( "#tags" ).autocomplete({
        source: 'suggest.php',
        minLength:1

    });
  } );
</script>

in myScript.js under js folder, how would I access it? My full code below...

Code:
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
<script>
  $( function() {
    $( "#tags" ).autocomplete({
        source: 'suggest.php',
        minLength:1

    });
  } );
</script>

<form action="" method="post">   
Name:   <input type="text" name="tags" id="tags" value="<?php echo isset($_POST['tags']) ? $_POST['tags'] : '' ?>"/>
</form>