Auto complete/suggest in wordpress

Hi guys, After a longtime i’m coming to my blog due to my work tension. I have learned new thing today auto suggest or auto complete in WordPress. I have creating a plugin for income tax calculator in that i need to do auto suggest or auto complete for one of the field in the wp-admin section.

It’s very easy to do in WP. They had already predefined jQuery Suggest we need to enqueue the script and then your function.

In your function script add this line

wp_enqueue_script(‘suggest’);

Then add the style

wp_enqueue_style(‘suggest’);

Then your function

jQuery(function() {
jQuery(“#textboxID”).suggest(“yourcustomscript.php”);
});

In “yourcustomscript.php”

  • Connects to the WP DB
  • Queries the table for the data you want
  • Convert the result set into an associative array (or pull it from the DB as one)

Thats all your result

Advertisements