I want to have an auto-complete or auto-suggest function on a (search) form:
When a user begins to type, it suggests post titles that have matching text.
I’d also like it to display some meta-data (a number) that I have stored related to each custom post. Example:
If I type “A”, it suggest “Apples (13), Aardvarks(51), Astronauts (21)”, etc.
Yes this is possible.
You can use jQuery Auto Suggest which is included with WordPress http://codex.wordpress.org/Function_Reference/wp_enqueue_script
With this you can write a form that does a Ajax lookup to the the Ajax URL handler.
Which you can add_action onto. http://codex.wordpress.org/AJAX_in_Plugins
So you can ajax lookup and then on the action side you can just perform a get_posts to match titles, or a raw sql Query. And return what is needed.
That should help, if I get time shortly I might write a full code solution.
But the bulk of it is a whole plugin to help power the lookup.
Edit: Here we go, something like this should do it, haven’t tested it just wrote it off the top of my head.
Update: Escape the Entered text, narrow by custom post type and to published posts only
2012-11-21 Edit: updated typo in code sample.