Using autocomplete with post_tag taxonomy on attachments
Using autocomplete with post_tag taxonomy on attachments
Using autocomplete with post_tag taxonomy on attachments
Can’t Get jQuery AutoComplete to work in WordPress (jQuery Hide/show works)
I would install the packages into your project. That will give you the auto-complete you’re looking for: npm install @wordpress/block-editor This package will not be bundled with your JS as the dependency extraction plugin converts the references to access them on the wp global.
Auto complete is most likely not working on the extra fields because they are added with javascript dynamically, and when you make your javascript .autocomplete() call, it runs on page load. Your dynamically created fields do not exist yet to have autocomplete hooked with them. Try this. jQuery(document).on(“keydown”, “.post_email_repeatable”, function(){ jQuery(this).autocomplete({ source: “get_posts.php”, minLength: 1 …
Your first example works fine with some minor alteration ( I will add it below), as can be seen here, http://jsfiddle.net/cDtv4/. What you need to do is make sure the actual jquery and jquery-ui (and possibly the jquery-ui.css) scripts are loading on the page you want this to work on. You can do this by …
if(isset($_GET[‘get_tags’])): $output = array(); foreach(get_terms(‘post_tag’) as $key => $term): // filter by $_GET[‘q’] here if you need to, // for eg. if(strpos($term->name, $_GET[‘q’]) !== false)… $output[$key][‘value’] = $key; $output[$key][‘name’] = $term->name; endforeach; header(“Content-type: application/json”); echo json_encode($output); die(); endif; in this case your js would be something like: $(“#input_1_3”).autoSuggest( “http://yoursite.com/?get_tags=1”, {selectedItemProp: “name”, searchObjProps: “name”});
I would use .ajax() instead of .suggest() in your jQuery. jQuery.ajax({ type : “post”, url : myAjax.ajaxurl, data : { action: ‘se_lookup’, }, success: function( result ) { console.log(result); } }); You should now receive the values back from the SQL.
Without changing anything, everything seems OK today. The auto-suggest works and suggests me existing tags when I begin to type a word… I don’t know why but maybe there was a problem because I’ve firstly created this custom taxonomy as hierachical before I decided to change it to non-hierarchical.
jQuery autcomplete not working
Tagit with json and autocomplete