I'm using the following jQuery to auto-populate a text input field in a custom Wordpress search:
$(window).load(function(){
var availableTags = [
"Option A",
"Option B",
"Option C",
"Option D"
];
$( "#option_field" ).autocomplete({
source: availableTags
});
This works great but I actually want the jQuery to pull in these results from some custom field options in my posts. I have a custom field in each post called 'Options'. Can I get the jQuery to pull in all the available options from this custom field then auto-populate my input field. For example if:
Post 1 has an 'Option' custom field entry of 'Chips'
Post 2 has an 'Option' custom field entry of 'Fish'
Post 3 has an 'Option' custom field entry of 'Cheese'
Post 4 has an 'Option' custom field entry of 'Cheese'
Post 5 has an 'Option' custom field entry of 'Fish'
When typing in the search field, there will be three autopopulate options of Fish, Chips, Cheese.
Thanks for any pointers!