jQuery ajax call throws an HTTP 302

I’d say, just skip that: cookie: encodeURIComponent(document.cookie) There’s no need to post any cookies on XHR – the browser handles that. Well, how about something like that instead (untested): data:{‘term’:encodeURIComponent($.term)} Most easy is to use FireBug, open Net panel and inspect both HTTP headers.

Implement Autocomplete for a custom field on WordPress Plugin Frontend

Please refer to wp_script_is( $handle ) to check if a script is already enqueued or registered. It’s a good idea to check before registering / loading a new script in WordPress. Since jQuery is included with WordPress and assuming you’re already using a custom WordPress theme I’m going to say it’s most likely already loaded. … Read more

How to add autocomplete to custom taxonomy for CPT

The logic in the tax query is very unlikely to verify true. Look at it: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘zip_code’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), array( ‘taxonomy’ => ‘city_served’, ‘field’ => ‘slug’, ‘terms’ => array( $term ), ), ), If you read the tax query, it … Read more

Allow AJAX call to other roles than admin

All the WordPress AJAX calls should be handled by the admin-ajax.php, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file: add_action( ‘wp_ajax_prefix_update_post’, ‘prefix_update_post’ ); add_action( ‘wp_ajax_nopriv_prefix_update_post’, ‘prefix_update_post’ ); Be sure to add some validation … Read more

Append Auto Suggest list to specific html tag?

You should care about tag input classes and CSS. All casses can be set in JS function: jQuery(document).ready(function ($) { $(‘#wpx_tags’).suggest( window.ajaxurl + “?action=wpx_tag_search”, { multiple:true, multipleSep: “,”, resultsClass: ‘wpx_ac_results’, selectClass: ‘wpx_ac_over’, matchClass: ‘wpx_ac_match’, } ); }); So, this will add wpx_ac_results class to the result list . And this CSS should fix it: .wpx_ac_results … Read more

Autoprediction / Autocomplete Search with Meta Keys

If you want to show custom field values, you can’t use WP_Query that select posts. It seems to me that the only available way is to write a sql query and execute it in $wpdb. global $wpdb; if ( isset($_POST[‘search’]) == false || empty($_POST[‘search’]) ) wp_send_json_success( $array() ); $s = $_POST[‘search’]; $meta_keys = [‘PLZ’, ‘ort’, … Read more