Forums › Forums › Search & Filter Pro › Autosuggest
Tagged: ajax, autocomplete, autofill, autosuggest, cpt, post type
- This topic has 6 replies, 2 voices, and was last updated 10 years, 1 month ago by Anonymous.
-
Anonymous(Private) September 25, 2014 at 11:55 am #5036
Hello! Your plugin rocks ๐
You know what would rock even more? Autosuggest.
It’d be really nice if the user could type in a textfield, then e.g. post meta would be filled out as he/she typed. This is so much more user friendly than getting a dropdown that consists of 1000+ items.If it’s already possible, please let me know! If not, then please consider making it a feature in a future release. We’re using your plugin for a really big website here in Norway and that kind of functionality would be a lifesaver.
Ross Moderator(Private) September 25, 2014 at 7:47 pm #5070Hey Mekom, did you try checking the “combo box” option for a dropdown or multiselect? I think this *might* be what you want? ๐
Anonymous(Private) September 25, 2014 at 9:40 pm #5083Thanks for your quick reply, Ross ๐
I wasn’t aware of the “combo box” so that’s awesome, but now I’ve a different problem unfortunately. I’m using a “relationship” custom field from the Advanced Custom Fields plugin, and when I hit the “auto suggest” button, it shows me the IDs naturally. The problem is that I need their titles instead. Do you’ve any ideas?
Ross Moderator(Private) September 26, 2014 at 6:01 pm #5135Hey Mekom
I don’t have much experience with the relationship fields and have not setup the plugin to support them – so I’m thinking this will not be easy – essentially you would have to modify the query itself which displays the “auto suggest” options, and I guess does some sort of clever joining to another value in the database – but this is not a simple task I think.
On a personal level, I would need to do a lot more research in to relationship fields and how exactly they work before I could offer any support for it, but if you want to have a look yourself in:
wp-content/plugins/search-filter-pro/admin/class-search-filter-admin.php
Then find the function
get_meta_values()
on line 528..This takes the meta key ($_POST[‘meta_key’]) and looks up all the possible unique values for that key – you would need to modify the query starting on line 537
$wpdb->query("...
Hope that helps!
Anonymous(Private) October 10, 2014 at 2:07 pm #5820Hi again, Ross!
Sry for the incredibly delayed answer. I think it’ll be easier for me to just create an autofill myself which targets a regular textfield from your plugin. Then get all my posts from a query.
Thanks for your detailed answer though, and it’d be cool if you made it work sometime in the future ๐
Anonymous(Private) October 17, 2014 at 3:53 pm #6078Hi again, Ross! I ended up making my own CPT autocomplete targeting a “search” field, but then it overwrites the real “search” field in the URL query. Why not just add a “post types” field that autocompletes an arbitrary CPT? This shouldn’t be too difficult to implement and will be an extremely useful feature! Then you won’t need to worry about the relationship stuff either.
The project I’m working on right now must be finished on the 24th, so I must probably make up my own code for this anyway, but if you’re planning on releasing an update before this or shortly after, please let me know ASAP ๐
Thanks,
Chris -
AuthorPosts