{"id":233354,"date":"2023-02-12T11:58:00","date_gmt":"2023-02-12T08:58:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=233354"},"modified":"2023-02-16T16:37:11","modified_gmt":"2023-02-16T13:37:11","slug":"stvorennja-avtozavershenogo-poshuku-v-wordpress-za-dopomogoju-kodu","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/uk\/stvorennja-avtozavershenogo-poshuku-v-wordpress-za-dopomogoju-kodu\/","title":{"rendered":"\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\u0433\u043e \u043f\u043e\u0448\u0443\u043a\u0443 \u0432 WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u043a\u043e\u0434\u0443"},"content":{"rendered":"\n<p>\u0426\u0435\u0439 \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u0438\u0445, \u0445\u0442\u043e \u0445\u043e\u0447\u0435 \u0440\u0435\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0448\u0443\u043a \u0456\u0437 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f\u043c \u0443 WordPress, \u0434\u0435 \u043c\u0438 \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044e\u0454\u043c\u043e \u0437\u0431\u0456\u0433\u0438, \u0449\u043e \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u044e\u0442\u044c\u0441\u044f.<\/p>\n<p>\u041c\u0438 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0454\u043c\u043e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0434\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0448\u0443\u043a\u0443 WordPress, \u0430\u043b\u0435 \u043a\u043e\u0434 \u0434\u0443\u0436\u0435 \u0433\u043d\u0443\u0447\u043a\u0438\u0439, \u0442\u043e\u043c\u0443 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0437\u0430\u043f\u0438\u0442 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0441\u0432\u043e\u0457\u0445 \u043f\u043e\u0442\u0440\u0435\u0431. \u041d\u0435\u0437\u0430\u043b\u0435\u0436\u043d\u043e \u0432\u0456\u0434 \u0442\u043e\u0433\u043e, \u0447\u0438 \u0446\u0435 \u0431\u0456\u043b\u044c\u0448 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u0438\u0439 \u0437\u0430\u043f\u0438\u0442 \u0437\u0430 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0446\u044c\u043a\u0438\u043c \u0442\u0438\u043f\u043e\u043c \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043c\u0435\u0442\u0430 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0456\u044f\u043c\u0438 \u0430\u0431\u043e \u0437\u0430\u043f\u0438\u0442\u0438 \u0449\u043e\u0434\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0456\u043d\u0448\u043e\u0433\u043e \u0442\u0438\u043f\u0443 \u0432\u043c\u0456\u0441\u0442\u0443, \u044f\u043a-\u043e\u0442 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456\u0432, \u0447\u0438 \u0449\u043e\u0441\u044c \u0440\u0443\u0447\u043d\u0435 \u0437 \u0431\u0430\u0437\u0438 \u0434\u0430\u043d\u0438\u0445. \u0412\u0438 \u0442\u0430\u043a\u043e\u0436 \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0435\u0433\u043a\u043e \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0434\u043e \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0446\u044c\u043a\u043e\u0433\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u043f\u043e\u0448\u0443\u043a\u0443 \u0437\u0430\u043c\u0456\u0441\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u0448\u0443\u043a\u0443 WordPress.<\/p>\n<h2>\u0429\u043e \u043c\u0438 \u0437\u0440\u043e\u0431\u0438\u043c\u043e<\/h2>\n<p>\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u2013 \u0446\u0435 \u043f\u043e\u043b\u0435 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430, \u044f\u043a\u0435 \u0437&#8217;\u044f\u0432\u043b\u044f\u0454\u0442\u044c\u0441\u044f \u043f\u0456\u0434 \u043f\u043e\u043b\u0435\u043c \u043f\u043e\u0448\u0443\u043a\u0443 \u0442\u0430 \u043f\u043e\u043a\u0430\u0437\u0443\u0454 \u0437\u0431\u0456\u0433\u0438 \u043f\u0456\u0434 \u0447\u0430\u0441 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f. \u041f\u0456\u0441\u043b\u044f \u043d\u0430\u0442\u0438\u0441\u043a\u0430\u043d\u043d\u044f \u043d\u0430 \u0437\u0431\u0456\u0433 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043d\u0430\u0434\u0441\u0438\u043b\u0430\u0454 \u0432\u0430\u0441 \u0434\u043e \u043f\u043e\u0441\u0442\u0456\u0439\u043d\u043e\u0433\u043e \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u0446\u044e \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e. \u0426\u0435 \u043d\u0430\u0434\u0430\u0454 \u043a\u0456\u043d\u0446\u0435\u0432\u043e\u043c\u0443 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0435\u0432\u0456 \u0448\u0432\u0438\u0434\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u0456\u0431 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0457 \u043f\u043e \u0432\u0430\u0448\u043e\u043c\u0443 \u0432\u043c\u0456\u0441\u0442\u0443, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u0439\u043e\u043c\u0443 \u043d\u0435 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0431\u0443\u0434\u0435 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0456\u0432 \u043f\u043e\u0448\u0443\u043a\u0443. \u041c\u0438 \u0431\u0443\u0434\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 AJAX \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0456\u0439\u043d\u043e\u0433\u043e \u043e\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u0437\u0431\u0456\u0433\u0456\u0432, \u043f\u043e\u043a\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 \u0432\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442.<\/p>\n<p><a href=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-153844-61e51414137d1.png\" data-rel=\"lightbox\"><img decoding=\"async\" class=\"SDStudio-light-box-enable SDStudio-editor-tools-md-imp\" src=\"https:\/\/wordpress.mediadoma.com\/wp-content\/uploads\/2022\/01\/post-153844-61e51414137d1.png\" alt=\"\u0421\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043e\u0433\u043e \u043f\u043e\u0448\u0443\u043a\u0443 \u0432 WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u043a\u043e\u0434\u0443\"><\/a><\/p>\n<p>\u0410\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0433\u0435\u043d\u0435\u0440\u0443\u0454\u0442\u044c\u0441\u044f \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <a href=\"https:\/\/jqueryui.com\/autocomplete\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">jQuery UI Autocomplete<\/a>, \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e, \u044f\u043a\u0438\u0439 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043e \u0434\u043e WordPress \u0437\u0430 \u0437\u0430\u043c\u043e\u0432\u0447\u0443\u0432\u0430\u043d\u043d\u044f\u043c.<\/p>\n<h2>\u041d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u043d\u043d\u044f \u043a\u043e\u0434\u0443<\/h2>\n<p>\u0412\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0431\u0443\u0434\u0435 \u0434\u043e\u0434\u0430\u0442\u0438 \u043a\u043e\u0434 \u0443 <code>functions.php<\/code>PHP-\u0444\u0430\u0439\u043b \u0442\u0435\u043c\u0438 \u0430\u0431\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043f\u043b\u0430\u0433\u0456\u043d\u0430. \u0426\u0435\u0439 \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a \u0437\u0430\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0439 \u043d\u0430 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u0456 \u0439\u043e\u0433\u043e \u0432 \u0442\u0435\u043c\u0443. \u041d\u0430\u043b\u0430\u0448\u0442\u0443\u0439\u0442\u0435 \u0448\u043b\u044f\u0445\u0438 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0432\u0430\u0448\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0443.<\/p>\n<p>\u041f\u0435\u0440\u0448\u0438\u043c \u043a\u0440\u043e\u043a\u043e\u043c \u0454 \u200b\u200b\u0441\u0442\u0432\u043e\u0440\u0435\u043d\u043d\u044f \u0444\u0430\u0439\u043b\u0443 Javascript, \u044f\u043a\u0438\u0439 \u043c\u0456\u0441\u0442\u0438\u0442\u0438\u043c\u0435 \u043d\u0430\u0448 \u043a\u043e\u0434 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0443 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f. \u0429\u043e \u0441\u0442\u043e\u0441\u0443\u0454\u0442\u044c\u0441\u044f \u0446\u044c\u043e\u0433\u043e \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a\u0430, \u044f \u0441\u0442\u0432\u043e\u0440\u044e \u043f\u043e\u0440\u043e\u0436\u043d\u0456\u0439 <code>autocomplete.js<\/code>\u0444\u0430\u0439\u043b \u0443 <code>assets\/js\/<\/code>\u043f\u0430\u043f\u0446\u0456 \u043c\u043e\u0454\u0457 \u0442\u0435\u043c\u0438. \u0412\u0438 \u0432\u0438\u0440\u0456\u0448\u0443\u0454\u0442\u0435, \u043a\u0443\u0434\u0438 \u0432\u0438 \u0440\u043e\u0437\u043c\u0456\u0441\u0442\u0438\u0442\u0435 \u0441\u0432\u0456\u0439 \u0444\u0430\u0439\u043b, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0448\u043b\u044f\u0445\u0438 \u043d\u0438\u0436\u0447\u0435. \u041c\u0438 \u043f\u043e\u0432\u0435\u0440\u043d\u0435\u043c\u043e\u0441\u044f \u0434\u043e \u0446\u044c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0443 \u043f\u0456\u0441\u043b\u044f \u0442\u043e\u0433\u043e, \u044f\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e \u0439\u043e\u0433\u043e \u0432 \u0447\u0435\u0440\u0433\u0443 \u0432 WordPress.<\/p>\n<h3>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0443 \u0447\u0435\u0440\u0433\u0443<\/h3>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0432 \u0447\u0435\u0440\u0433\u0443 \u043d\u0430\u0448 \u0444\u0430\u0439\u043b Javascript \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f, \u0430 \u0442\u0430\u043a\u043e\u0436 \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0442\u0438\u0441\u044f, \u0449\u043e jQuery \u0442\u0430 jQuery UI Autocomplete. \u041a\u0440\u0456\u043c \u0442\u043e\u0433\u043e, WordPress \u043d\u0435 \u043c\u0456\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0438\u043b\u0456\u0432 \u0434\u043b\u044f \u0431\u0456\u0431\u043b\u0456\u043e\u0442\u0435\u043a jQuery UI, \u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u0442\u0430\u043a\u043e\u0436 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044e \u0441\u0442\u0438\u043b\u0456\u0432 \u0434\u043b\u044f jQuery UI \u0437 Google CDN. \u0417\u0432\u0438\u0447\u0430\u0439\u043d\u043e, \u0446\u0435 \u043d\u0435\u043e\u0431\u043e\u0432\u2019\u044f\u0437\u043a\u043e\u0432\u043e. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0434\u0430\u0442\u0438 CSS \u0456\u043d\u0448\u0438\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0430\u0431\u043e, \u043c\u043e\u0436\u043b\u0438\u0432\u043e, \u0432\u0438 \u0432\u0456\u0434\u0434\u0430\u0454\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0430\u0433\u0443 \u0441\u0442\u0438\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u0439\u043e\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u0456\u0439\u043d\u043e.<\/p>\n<p>\u041c\u0438 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c\u043e \u0432\u0441\u0456 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 \u0442\u0430 \u0441\u0442\u0438\u043b\u0456 \u0443 \u0444\u0443\u043d\u043a\u0446\u0456\u044e, \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0443 \u0434\u043e <code>wp_enqueue_scripts<\/code>:<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    wp_enqueue_script('autocomplete-search', get_stylesheet_directory_uri(). '\/assets\/js\/autocomplete.js', \n        ['jquery', 'jquery-ui-autocomplete'], null, true);\n});<\/code><\/pre>\n<p>\u0412\u0438\u043a\u043b\u0438\u043a <code>[wp_enqueue_script](https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_script\/)()<\/code>\u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u0432\u0438\u0449\u0435 \u0434\u043e\u0434\u0430\u0441\u0442\u044c \u043d\u0430\u0448 \u0449\u043e\u0439\u043d\u043e \u0441\u0442\u0432\u043e\u0440\u0435\u043d\u0438\u0439 \u0444\u0430\u0439\u043b Javascript \u0456\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0438\u043c\u0438 \u0437\u0430\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 (\u043c\u0430\u0441\u0438\u0432 \u044f\u043a \u0442\u0440\u0435\u0442\u0456\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440). \u0426\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0443\u0454, \u0449\u043e WordPress \u0434\u043e\u0434\u0430\u0454 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457 jQuery \u0442\u0430 jQuery UI Autocomplete \u0443 \u043d\u0430\u0448 \u0435\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 WordPress.<\/p>\n<p>\u0414\u0430\u043b\u0456 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043d\u0430\u0434\u0430\u0442\u0438 \u0434\u0435\u044f\u043a\u0456 \u0437\u043c\u0456\u043d\u043d\u0456, \u0434\u043e \u044f\u043a\u0438\u0445 \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0434\u043e\u0441\u0442\u0443\u043f \u0456\u0437 \u043d\u0430\u0448\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f. \u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0437\u043d\u0430\u0442\u0438 URL-\u0430\u0434\u0440\u0435\u0441\u0443 AJAX, \u0456 \u043c\u0438 \u0442\u0430\u043a\u043e\u0436 \u0445\u043e\u0447\u0435\u043c\u043e \u0434\u043e\u0434\u0430\u0442\u0438 <a href=\"https:\/\/codex.wordpress.org\/WordPress_Nonces\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">nonce<\/a> \u0434\u043b\u044f \u0431\u0435\u0437\u043f\u0435\u043a\u0438. \u041c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0437\u0440\u043e\u0431\u0438\u0442\u0438 \u0446\u0435 \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>[wp_localize_script](https:\/\/developer.wordpress.org\/reference\/functions\/wp_localize_script\/)()<\/code>:<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    wp_enqueue_script('autocomplete-search', get_stylesheet_directory_uri(). '\/assets\/js\/autocomplete.js', \n        ['jquery', 'jquery-ui-autocomplete'], null, true);\n    wp_localize_script('autocomplete-search', 'AutocompleteSearch', [\n        'ajax_url' =&gt; admin_url('admin-ajax.php'),\n        'ajax_nonce' =&gt; wp_create_nonce('autocompleteSearchNonce')\n    ]);\n});<\/code><\/pre>\n<p>\u0424\u0443\u043d\u043a\u0446\u0456\u044f <code>wp_localize_script()<\/code>\u0441\u0442\u0432\u043e\u0440\u0438\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443 \u0437\u043c\u0456\u043d\u043d\u0443 Javascript <code>AutocompleteSearch<\/code>\u0456\u0437 \u0434\u0432\u043e\u043c\u0430 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u044f\u043c\u0438; <code>ajax_url<\/code>\u0456 <code>ajax_nonce<\/code>. \u0417\u0430\u0432\u0434\u044f\u043a\u0438 \u0446\u044c\u043e\u043c\u0443 \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432 \u043d\u0430\u0448\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u0456 Javascript \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438, \u043d\u0430\u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f URL-\u0430\u0434\u0440\u0435\u0441\u0438 WordPress AJAX \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>AutocompleteSearch.ajax_url<\/code>.<\/p>\n<p>\u041d\u0430\u0440\u0435\u0448\u0442\u0456 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0434\u043e\u0434\u0430\u0442\u0438 \u0442\u0440\u043e\u0445\u0438 \u0441\u0442\u0438\u043b\u044e. \u042f\u043a \u0443\u0436\u0435 \u0437\u0433\u0430\u0434\u0443\u0432\u0430\u043b\u043e\u0441\u044f, WordPress \u043d\u0435 \u043c\u0456\u0441\u0442\u0438\u0442\u044c \u0436\u043e\u0434\u043d\u0438\u0445 \u0441\u0442\u0438\u043b\u0456\u0432 \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 jQuery, \u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0434\u043e\u0434\u0430\u0442\u0438 \u0434\u0435\u044f\u043a\u0456 \u0441\u0430\u043c\u0456. \u042f \u0432\u0438\u0431\u0440\u0430\u0432 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/developers.google.com\/speed\/libraries\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Google CDN<\/a>. \u0410\u043b\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0437\u043d\u0430\u0442\u0438 \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0456\u0457 jQuery UI, \u0449\u043e\u0431 \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0439\u043e\u0433\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044e \u0441\u0442\u0438\u043b\u0456\u0432. \u041c\u0438 \u043c\u043e\u0433\u043b\u0438 \u0431 \u0436\u043e\u0440\u0441\u0442\u043a\u043e \u0437\u0430\u043a\u043e\u0434\u0443\u0432\u0430\u0442\u0438 \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0456\u0457, \u0430\u043b\u0435 \u044f \u043d\u0435 \u043f\u0440\u0438\u0445\u0438\u043b\u044c\u043d\u0438\u043a \u0436\u043e\u0440\u0441\u0442\u043a\u043e\u0433\u043e \u043a\u043e\u0434\u0443\u0432\u0430\u043d\u043d\u044f. \u041d\u0438\u0436\u0447\u0435 \u0432\u0438 \u0437\u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u0433\u0430\u0440\u043d\u0438\u0439 \u0442\u0440\u044e\u043a, \u0449\u043e\u0431 \u0437\u0430\u0437\u0434\u0430\u043b\u0435\u0433\u0456\u0434\u044c \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u044e \u043f\u0440\u043e \u0432\u0435\u0440\u0441\u0456\u044e \u0456\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0443 jQuery, \u0449\u043e \u0437\u0431\u0435\u0440\u0456\u0433\u0430\u0454\u0442\u044c\u0441\u044f \u0432 WordPress.<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    ...\n\u00a0\n    $wp_scripts = wp_scripts();\n    wp_enqueue_style('jquery-ui-css',\n        '\/\/ajax.googleapis.com\/ajax\/libs\/jqueryui\/'. $wp_scripts-&gt;registered['jquery-ui-autocomplete']-&gt;ver. '\/themes\/smoothness\/jquery-ui.css',\n        false, null, false\n    );\n});<\/code><\/pre>\n<p>\u041c\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u043c\u043e <code>[wp_enqueue_style](https:\/\/developer.wordpress.org\/reference\/functions\/wp_enqueue_style\/)()<\/code>\u0434\u043b\u044f \u0440\u0435\u0454\u0441\u0442\u0440\u0430\u0446\u0456\u0457 \u0442\u0430 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u043d\u043e\u0432\u043e\u0457 \u0442\u0430\u0431\u043b\u0438\u0446\u0456 \u0441\u0442\u0438\u043b\u0456\u0432 \u0456\u0437 \u043d\u0430\u0434\u0430\u043d\u0438\u043c \u0448\u043b\u044f\u0445\u043e\u043c CDN \u044f\u043a \u0434\u0440\u0443\u0433\u0438\u043c \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u0429\u043e\u0431 \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0434\u0456\u0439\u0441\u043d\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u0432\u0435\u0440\u0441\u0456\u0457 jQuery UI, \u043c\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u043c\u043e \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u044e, \u043d\u0430\u0434\u0430\u043d\u0443 \u0444\u0443\u043d\u043a\u0446\u0456\u0454\u044e <code>[wp_scripts](https:\/\/developer.wordpress.org\/reference\/functions\/wp_scripts\/)()<\/code>.<\/p>\n<p>\u0406 \u0446\u0435 \u0432\u0441\u0435, \u0449\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0457\u0432 \u0443 \u0447\u0435\u0440\u0433\u0443!<\/p>\n<h3>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044f Javascript<\/h3>\n<p>\u041f\u043e\u0432\u0435\u0440\u043d\u0435\u043c\u043e\u0441\u044f \u0434\u043e \u043d\u0430\u0448\u043e\u0433\u043e <code>autocomplete.js<\/code>\u0444\u0430\u0439\u043b\u0443. \u041c\u0438 \u0437\u043d\u0430\u0454\u043c\u043e, \u0449\u043e \u043a\u043e\u043b\u0438 \u0446\u0435\u0439 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0439 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0454\u0442\u044c\u0441\u044f, jQuery \u0442\u0430 jQuery UI Autocomplete \u0432\u0436\u0435 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u044e\u0442\u044c\u0441\u044f, \u0456 \u043c\u0438 \u0442\u0430\u043a\u043e\u0436 \u043c\u0430\u0454\u043c\u043e \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0457 \u0437\u043c\u0456\u043d\u043d\u043e\u0457 \u0437 \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e\u044e \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u0454\u044e. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0447\u043d\u0435\u043c\u043e \u0437 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u043d\u043d\u044f \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0456 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430 jQuery, \u0449\u043e\u0431 \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0438\u0442\u0438 \u0432\u0438\u043a\u043e\u043d\u0430\u043d\u043d\u044f \u043d\u0430\u0448\u043e\u0433\u043e \u043a\u043e\u0434\u0443 \u043f\u0456\u0441\u043b\u044f \u0442\u043e\u0433\u043e, \u044f\u043a DOM \u0431\u0443\u0434\u0435 \u0433\u043e\u0442\u043e\u0432\u0438\u0439.<\/p>\n<pre><code>jQuery(function($) {\n    \/\/ All code in here\n});<\/code><\/pre>\n<p>\u042f\u043a\u0449\u043e \u043c\u0438 \u0437\u0432\u0435\u0440\u043d\u0435\u043c\u043e\u0441\u044f \u0434\u043e <a href=\"https:\/\/jqueryui.com\/autocomplete\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0456\u0457 jQuery UI Autocomplete,<\/a> \u0442\u043e \u0434\u0456\u0437\u043d\u0430\u0454\u043c\u043e\u0441\u044f, \u0449\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0441\u0442\u0432\u043e\u0440\u0438\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 jQuery, \u043d\u0430\u0446\u0456\u043b\u0435\u043d\u0438\u0439 \u043d\u0430 \u043f\u043e\u043b\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f, \u0456 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e <code>autocomplete()<\/code>\u043d\u0430 \u043d\u044c\u043e\u043c\u0443.<\/p>\n<p>\u0426\u0435 \u043c\u043e\u043c\u0435\u043d\u0442, \u0434\u0435 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u043a\u043e\u0434 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0441\u0432\u043e\u0457\u0445 \u043f\u043e\u0442\u0440\u0435\u0431. \u0423 \u0446\u044c\u043e\u043c\u0443 \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a\u0443 \u0431\u0443\u0434\u0435 \u0437\u0430\u0441\u0442\u043e\u0441\u043e\u0432\u0430\u043d\u043e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0434\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043f\u043e\u0448\u0443\u043a\u0443 WordPress (\u044f\u043a\u0435 \u0437\u0430\u0437\u0432\u0438\u0447\u0430\u0439 \u0434\u043e\u0434\u0430\u0454\u0442\u044c\u0441\u044f \u0432 \u0442\u0435\u043c\u0443 \u0448\u043b\u044f\u0445\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u0443 \u043f\u043e\u0448\u0443\u043a\u0443 \u0430\u0431\u043e \u044f\u043a \u0432\u0456\u0434\u0436\u0435\u0442). \u041d\u0430\u0437\u0432\u0438 \u043a\u043b\u0430\u0441\u0456\u0432 \u043f\u043e\u0448\u0443\u043a\u043e\u0432\u0438\u0445 \u0434\u0430\u043d\u0438\u0445 \u043c\u043e\u0436\u0443\u0442\u044c \u0432\u0456\u0434\u0440\u0456\u0437\u043d\u044f\u0442\u0438\u0441\u044f \u0432\u0456\u0434 \u0442\u0435\u043c\u0438 \u0434\u043e \u0442\u0435\u043c\u0438. \u0410\u043b\u0435 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0446\u0456\u043b\u0438\u0442\u0438\u0441\u044f \u043d\u0430 \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u044c\u043d\u0435 \u043f\u043e\u043b\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u0430\u0431\u043e \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 \u043f\u043e\u0448\u0443\u043a \u0443 \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0456. \u0412\u0441\u0435, \u0449\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0437\u0440\u043e\u0431\u0438\u0442\u0438, \u0446\u0435 \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 jQuery \u043d\u0430 \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u0438\u0439 \u0432\u0430\u043c \u0432\u0445\u0456\u0434.<\/p>\n<p>\u0423 \u043c\u043e\u0457\u0439 \u0442\u0435\u043c\u0456 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0435 \u043f\u043e\u043b\u0435 \u043f\u043e\u0448\u0443\u043a\u0443 WordPress \u043c\u0430\u0454 \u043a\u043b\u0430\u0441 <code>.search-field<\/code>. \u042f \u0442\u0430\u043a\u043e\u0436 \u0434\u043e\u0434\u0430\u044e \u043d\u0430\u0437\u0432\u0443 \u043a\u043b\u0430\u0441\u0443 \u0431\u0430\u0442\u044c\u043a\u0456\u0432\u0441\u044c\u043a\u043e\u0457 \u0444\u043e\u0440\u043c\u0438, \u0449\u043e\u0431 \u0449\u0435 \u0431\u0456\u043b\u044c\u0448\u0435 \u0437\u0432\u0443\u0437\u0438\u0442\u0438 \u0439\u043e\u0433\u043e, \u0449\u043e\u0431 \u043c\u0438 \u043d\u0435 \u0440\u0438\u0437\u0438\u043a\u0443\u0432\u0430\u043b\u0438 \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0434\u043e \u0447\u043e\u0433\u043e\u0441\u044c \u0456\u043d\u0448\u043e\u0433\u043e, \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u044e\u0447\u0438 \u0442\u043e\u0439 \u0441\u0430\u043c\u0438\u0439 \u043a\u043b\u0430\u0441.<\/p>\n<p>\u0412\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0456\u0457 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 \u0432\u0438\u043a\u043b\u0438\u043a AJAX \u0443 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 <code>source<\/code>(\u044f\u043a\u0438\u0439 \u043c\u0430\u0454 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0438 \u043c\u0430\u0441\u0438\u0432 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0456\u0432 \u0434\u043b\u044f \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044f \u0432 \u0430\u0432\u0442\u043e\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u0456). \u0414\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u043c\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0454\u043c\u043e <a href=\"https:\/\/api.jquery.com\/jquery.ajax\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">Ajax-\u0444\u0443\u043d\u043a\u0446\u0456\u044e jQuery<\/a> :<\/p>\n<pre><code>jQuery(function($) {\n    $('.search-form .search-field').autocomplete({\n        source: function(request, response) {\n            $.ajax({\n                dataType: 'json',\n                url: AutocompleteSearch.ajax_url,\n                data: {\n                    term: request.term,\n                    action: 'autocompleteSearch',\n                    security: AutocompleteSearch.ajax_nonce,\n                },\n                success: function(data) {\n                    response(data);\n                }\n            });\n        },\n    });\n});<\/code><\/pre>\n<p>\u0423 \u0440\u044f\u0434\u043a\u0443 <code>#2<\/code>\u043c\u0438 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u044f\u0454\u043c\u043e jQuery UI Autocomplete, \u0434\u043e \u044f\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u043c\u0438 \u0445\u043e\u0447\u0435\u043c\u043e \u0437\u0430\u0441\u0442\u043e\u0441\u0443\u0432\u0430\u0442\u0438 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f. \u0417\u043c\u0456\u043d\u0456\u0442\u044c \u0446\u0435\u0439 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431.<\/p>\n<p>\u0423 \u043d\u0430\u0439\u043f\u0440\u043e\u0441\u0442\u0456\u0448\u0456\u0439 \u0444\u043e\u0440\u043c\u0456 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043e\u0447\u0456\u043a\u0443\u0454 \u043c\u0430\u0441\u0438\u0432 \u043e\u0431\u2019\u0454\u043a\u0442\u0456\u0432 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f <code>source<\/code>\u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456. \u0422\u0443\u0442 \u043c\u0438 \u0441\u0442\u0432\u043e\u0440\u044e\u0454\u043c\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0437 \u0434\u0432\u043e\u043c\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438; <code>request<\/code>\u043c\u0456\u0441\u0442\u0438\u0442\u044c \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u044e \u043f\u0440\u043e \u043d\u0430\u0448\u0435 \u0432\u0432\u0435\u0434\u0435\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f (<code>request.term<\/code>), \u0430 <code>response<\/code>\u0442\u0430\u043a\u043e\u0436 \u043f\u0440\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0437\u0432\u043e\u0440\u043e\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u043a\u043b\u0438\u043a\u0443, \u044f\u043a\u0443 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u0442\u0438 \u0442\u0430 \u043d\u0430\u0434\u0430\u0442\u0438 \u0434\u0430\u043d\u0456. \u0426\u0435 \u0442\u0435, \u0449\u043e \u043c\u0438 \u0440\u043e\u0431\u0438\u043c\u043e \u0443 \u0444\u0443\u043d\u043a\u0446\u0456\u0457 AJAX <code>success<\/code>\u0443 \u0440\u044f\u0434\u043a\u0443 <code>#13<\/code>.<\/p>\n<p>\u0421\u0430\u043c \u0432\u0438\u043a\u043b\u0438\u043a AJAX \u0434\u043e\u0441\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439. \u041c\u0438 \u0432\u0438\u0437\u043d\u0430\u0447\u0430\u0454\u043c\u043e \u0442\u0438\u043f \u0434\u0430\u043d\u0438\u0445 \u044f\u043a JSON \u2013 \u0446\u0435 \u0432\u0430\u0436\u043b\u0438\u0432\u043e, \u0456\u043d\u0430\u043a\u0448\u0435 jQuery UI Autocomplete \u043d\u0435 \u0437\u043c\u043e\u0436\u0435 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438. \u041e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 <code>url<\/code>\u043c\u0438 \u043e\u0442\u0440\u0438\u043c\u0443\u0454\u043c\u043e \u0434\u043e\u0441\u0442\u0443\u043f <code>ajax_url<\/code>\u0434\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0457 \u0437\u043c\u0456\u043d\u043d\u043e\u0457, \u044f\u043a\u0443 \u043c\u0438 \u043b\u043e\u043a\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u043b\u0438 \u0434\u043e \u043d\u0430\u0448\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u044e \u0440\u0430\u043d\u0456\u0448\u0435; <code>AutocompleteSearch<\/code>. \u0406 \u044f\u043a <code>data<\/code>\u043c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0454\u043c\u043e \u043e\u0431&#8217;\u0454\u043a\u0442 \u0456\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0456\u0457. \u0412\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c <code>action<\/code>\u0454 \u043e\u0431\u043e\u0432\u2019\u044f\u0437\u043a\u043e\u0432\u043e\u044e \u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u0456\u0434\u043d\u043e\u044e \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u0433\u043e \u043a\u0440\u043e\u043a\u0443 \u2013 \u0432\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0446\u044c\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0438\u0442\u0443 AJAX \u0443 PHP. \u041c\u0438 \u0442\u0430\u043a\u043e\u0436 \u043f\u0435\u0440\u0435\u0434\u0430\u0454\u043c\u043e \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0442\u0435\u0440\u043c\u0456\u043d \u0443 input \u0456 nonce \u0437 \u043c\u0435\u0442\u043e\u044e \u0431\u0435\u0437\u043f\u0435\u043a\u0438.<\/p>\n<p>\u0426\u0435 \u0432\u0441\u0435 \u0434\u043b\u044f <code>sources<\/code>\u0432\u043b\u0430\u0441\u043d\u043e\u0441\u0442\u0456. \u0404 \u0449\u0435 \u043e\u0434\u043d\u0430 \u0440\u0456\u0447, \u044f\u043a\u0443 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0434\u043e\u0434\u0430\u0442\u0438 \u0432 \u043d\u0430\u0448 \u0441\u0446\u0435\u043d\u0430\u0440\u0456\u0439 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f. \u0417\u0430 \u0437\u0430\u043c\u043e\u0432\u0447\u0443\u0432\u0430\u043d\u043d\u044f\u043c \u0443 jQuery UI Autocomplete \u0432\u0438\u0431\u0456\u0440 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0454 \u0432\u0432\u0435\u0434\u0435\u043d\u0456 \u0434\u0430\u043d\u0456 \u0432\u0438\u0431\u0440\u0430\u043d\u0438\u043c \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c. \u041c\u0438 \u0445\u043e\u0447\u0435\u043c\u043e \u043f\u0435\u0440\u0435\u0441\u043f\u0440\u044f\u043c\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430 \u043d\u0430 URL-\u0430\u0434\u0440\u0435\u0441\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u043f\u0456\u0434 \u0447\u0430\u0441 \u0432\u0438\u0431\u043e\u0440\u0443 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0437\u0456 \u0441\u043f\u0438\u0441\u043a\u0443. \u041e\u0442\u0436\u0435, \u043c\u0438 \u0434\u043e\u0434\u0430\u0454\u043c\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0434\u043e <code>select<\/code>\u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456:<\/p>\n<pre><code>                ...\n                success: function(data) {\n                    response(data);\n                }\n            });\n        },      \n        select: function(event, ui) {\n            window.location.href = ui.item.link;\n        },\n    });\n});<\/code><\/pre>\n<p>\u0423 \u043c\u0430\u0441\u0438\u0432\u0456 \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0456\u0432, \u044f\u043a\u0438\u0439 \u043c\u0438 \u043f\u043e\u0432\u0435\u0440\u043d\u0435\u043c\u043e \u043f\u0456\u0441\u043b\u044f \u0432\u0438\u043a\u043b\u0438\u043a\u0443 AJAX (\u043c\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c\u043e \u0446\u0435 \u0434\u0430\u043b\u0456), \u043a\u043e\u0436\u0435\u043d \u0435\u043b\u0435\u043c\u0435\u043d\u0442 \u0454 \u043e\u0431\u2019\u0454\u043a\u0442\u043e\u043c \u0456\u0437 \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u044f\u043c\u0438. \u041c\u0438 \u0434\u043e\u0434\u0430\u043c\u043e \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u044c\u043d\u0443 <code>link<\/code>\u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u0434\u043e \u043a\u043e\u0436\u043d\u043e\u0433\u043e \u0435\u043b\u0435\u043c\u0435\u043d\u0442\u0430 (<code>ui.item<\/code>), \u044f\u043a\u0430 \u043c\u0456\u0441\u0442\u0438\u0442\u0438\u043c\u0435 \u043f\u043e\u0441\u0442\u0456\u0439\u043d\u0456 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u043d\u0430 \u043a\u043e\u0436\u043d\u0443 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e. \u041c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0454\u043c\u043e \u0446\u044e URL-\u0430\u0434\u0440\u0435\u0441\u0443, \u043d\u0430 <code>[window.location.href](https:\/\/www.w3schools.com\/js\/js_window_location.asp)<\/code>\u044f\u043a\u0443 \u0456\u043d\u0456\u0446\u0456\u044e\u0432\u0430\u0442\u0438\u043c\u0435\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0441\u043f\u0440\u044f\u043c\u0443\u0432\u0430\u043d\u043d\u044f \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430.<\/p>\n<p>\u0406 \u0446\u0435 \u0432\u0441\u0435 \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438\u043d\u0438 Javascript! \u0412\u0441\u0435, \u0449\u043e \u0437\u0430\u043b\u0438\u0448\u0438\u043b\u043e\u0441\u044f, \u0446\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u0438 \u0447\u0430\u0441\u0442\u0438\u043d\u0443 PHP, \u044f\u043a\u0430 \u0441\u043b\u0443\u0445\u0430\u0454 \u0437\u0430\u043f\u0438\u0442\u0438 AJAX \u0437 \u0434\u0456\u0454\u044e <code>autocompleteSearch<\/code>.<\/p>\n<h3>\u041f\u043e\u0432\u0435\u0440\u043d\u0435\u043d\u043d\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0456\u0432 \u0456\u0437 PHP \u0434\u043e \u0437\u0430\u043f\u0438\u0442\u0456\u0432 AJAX<\/h3>\n<p>\u0429\u043e\u0431 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u0457, \u044f\u043a\u0456 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0430\u044e\u0442\u044c \u043d\u0430 \u043f\u0435\u0432\u043d\u0456 \u0437\u0430\u043f\u0438\u0442\u0438 AJAX, \u043c\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u043c\u043e \u0445\u0443\u043a\u0438 <code>wp_ajax_{action}<\/code>(\u0432\u0456\u0434\u0432\u0456\u0434\u0443\u0432\u0430\u0447\u0456, \u044f\u043a\u0456 \u0432\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443) \u0456 <code>wp_ajax_nopriv_{action}<\/code>(\u0432\u0456\u0434\u0432\u0456\u0434\u0443\u0432\u0430\u0447\u0456, \u044f\u043a\u0456 \u043d\u0435 \u0432\u0432\u0456\u0439\u0448\u043b\u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443). \u041c\u0438 \u0432\u0438\u0437\u043d\u0430\u0447\u0438\u043b\u0438 \u0434\u0456\u044e, \u044f\u043a <code>autocompleteSearch<\/code>\u0443 \u043d\u0430\u0448\u043e\u043c\u0443 \u0437\u0430\u043f\u0438\u0442\u0456 AJAX \u0432\u0438\u0449\u0435. \u0417\u0432\u0435\u0440\u043d\u0456\u0442\u044c\u0441\u044f \u0434\u043e \u043c\u043e\u0454\u0457 <a href=\"https:\/\/wordpress.mediadoma.com\/uk\/posibnik-jak-pravilno-vikoristovuvati-ajax-u-wordpress\/\" title=\"\u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u044f\u043a\u0430 \u043f\u043e\u044f\u0441\u043d\u044e\u0454, \u044f\u043a \u043f\u0440\u0430\u0446\u044e\u0454 AJAX \u0443 WordPress\">\u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u044f\u043a\u0430 \u043f\u043e\u044f\u0441\u043d\u044e\u0454, \u044f\u043a \u043f\u0440\u0430\u0446\u044e\u0454 AJAX \u0443 WordPress<\/a>, \u044f\u043a\u0449\u043e \u0432\u0438 \u0437 \u0446\u0438\u043c \u043d\u0435 \u0437\u043d\u0430\u0439\u043e\u043c\u0456.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0454\u043c\u043e \u0446\u0435 \u0432 <code>functions.php<\/code>(\u0430\u0431\u043e \u0432 \u0456\u043d\u0448\u043e\u043c\u0443 \u043c\u0456\u0441\u0446\u0456 PHP, \u0434\u0435 \u0432\u0438 \u0434\u043e\u0434\u0430\u0454\u0442\u0435 \u0441\u0432\u0456\u0439 \u043a\u043e\u0434):<\/p>\n<pre><code>add_action('wp_ajax_nopriv_autocompleteSearch', 'awp_autocomplete_search');\nadd_action('wp_ajax_autocompleteSearch', 'awp_autocomplete_search');\nfunction awp_autocomplete_search() {\n    \/\/ echo result\n    die();\n}<\/code><\/pre>\n<p>\u0417\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u043e\u0433\u043e \u0432\u0438\u0449\u0435 \u043a\u043e\u0434\u0443 \u043c\u0438 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0430\u0454\u043c\u043e \u0442\u0443 \u0441\u0430\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0434\u043e \u0434\u0432\u043e\u0445 \u0445\u0443\u043a\u0456\u0432 AJAX. \u0423 \u0432\u0441\u0456\u0445 \u0444\u0443\u043d\u043a\u0446\u0456\u044f\u0445, \u044f\u043a\u0456 \u043f\u0456\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0456 \u0434\u043e \u0445\u0443\u043a\u0456\u0432 AJAX wp_ajax, \u043c\u0438 \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u043f\u0435\u0440\u0435\u043a\u043e\u043d\u0430\u0442\u0438\u0441\u044f, \u0449\u043e \u0437\u0430\u0432\u0436\u0434\u0438 <code>die()<\/code>\u0430\u0431\u043e <code>exit<\/code>\u0432 \u043a\u0456\u043d\u0446\u0456, \u0449\u043e\u0431 \u043c\u0438 \u043d\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0432\u0430\u043b\u0438 \u043d\u0435\u0431\u0430\u0436\u0430\u043d\u0438\u0439 \u0432\u0438\u0445\u0456\u0434. \u042f \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u044e <code>[wp_die](https:\/\/developer.wordpress.org\/reference\/functions\/wp_die\/)()<\/code>\u0444\u0443\u043d\u043a\u0446\u0456\u044e WordPress.<\/p>\n<p>\u041c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u0456 \u0434\u0430\u043d\u0456 \u0437 Javascript \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>$_REQUEST<\/code>(\u043f\u0440\u0430\u0446\u044e\u0454 \u044f\u043a \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0442\u0456\u0432 GET, \u0442\u0430\u043a \u0456 \u0434\u043b\u044f POST). \u0423 \u043d\u0430\u0448\u043e\u043c\u0443 \u043a\u043e\u0434\u0456 Javascript \u043c\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043b\u0438 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0442\u0435\u0440\u043c\u0456\u043d \u0443 \u043a\u043b\u044e\u0447 &quot; <code>term<\/code>&quot;. \u0426\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0454, \u0449\u043e \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u043e\u0442\u0440\u0438\u043c\u0430\u0442\u0438 \u0439\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u0432 <code>$_REQUEST['term']<\/code>. \u041f\u043e\u0442\u0456\u043c \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 \u0437\u0430\u043f\u0438\u0442 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0456 \u0446\u044c\u043e\u0433\u043e. \u041f\u0430\u043c\u2019\u044f\u0442\u0430\u0439\u0442\u0435, \u0449\u043e \u043c\u0438 \u0445\u043e\u0447\u0435\u043c\u043e \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u0442\u0438 \u043b\u0438\u0448\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438, \u044f\u043a\u0456 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0430\u044e\u0442\u044c \u0446\u044c\u043e\u043c\u0443 \u043f\u043e\u0448\u0443\u043a\u043e\u0432\u043e\u043c\u0443 \u0442\u0435\u0440\u043c\u0456\u043d\u0443.<\/p>\n<p>\u0426\u0435 \u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0443\u043d\u043a\u0442, \u0434\u0435 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u0437\u043c\u0456\u043d\u0438\u0442\u0438 \u0442\u0430 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u043a\u043e\u0434 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u043d\u043e \u0434\u043e \u0441\u0432\u043e\u0457\u0445 \u043f\u043e\u0442\u0440\u0435\u0431. \u0426\u0435\u0439 \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a \u0432\u0438\u043a\u043e\u043d\u0443\u0432\u0430\u0442\u0438\u043c\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0438\u0439 \u0437\u0430\u043f\u0438\u0442 \u0434\u043e \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439 \u0456 \u0441\u0442\u043e\u0440\u0456\u043d\u043e\u043a, \u0430\u043b\u0435 \u0432\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0437\u0430\u043f\u0438\u0442 \u0430\u0431\u043e \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 \u0437\u043e\u0432\u0441\u0456\u043c \u0456\u043d\u0448\u0438\u0439 \u0437\u0430\u043f\u0438\u0442 \u0434\u043e \u0456\u043d\u0448\u0438\u0445 \u0434\u0430\u043d\u0438\u0445. \u041c\u043e\u0436\u043b\u0438\u0432\u043e, \u0432\u0438 \u0432\u0456\u0434\u0434\u0430\u0454\u0442\u0435 \u043f\u0435\u0440\u0435\u0432\u0430\u0433\u0443 \u0430\u0431\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0454\u0442\u0435 \u0437\u0430\u043c\u0456\u0441\u0442\u044c \u0446\u044c\u043e\u0433\u043e \u0432\u0438\u043a\u043e\u043d\u0430\u0442\u0438 \u0437\u0430\u043f\u0438\u0442 SQL \u0432\u0440\u0443\u0447\u043d\u0443 (\u0446\u0435, \u0437\u0432\u0438\u0447\u0430\u0439\u043d\u043e, \u0431\u0456\u043b\u044c\u0448 \u0435\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 \u043f\u0430\u043c\u2019\u044f\u0442\u044c). \u0412\u0430\u0436\u043b\u0438\u0432\u043e\u044e \u0447\u0430\u0441\u0442\u0438\u043d\u043e\u044e \u0442\u0443\u0442 \u0454 \u043c\u0430\u0441\u0438\u0432, \u044f\u043a\u0438\u0439 \u043c\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0454\u043c\u043e \u0432 \u043a\u0456\u043d\u0446\u0456, \u044f\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0456\u0437\u0443\u0454\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f Javascript.<\/p>\n<pre><code>add_action('wp_ajax_nopriv_autocompleteSearch', 'awp_autocomplete_search');\nadd_action('wp_ajax_autocompleteSearch', 'awp_autocomplete_search');\nfunction awp_autocomplete_search() {\n    check_ajax_referer('autocompleteSearchNonce', 'security');\n    $search_term = $_REQUEST['term'];\n    if (!isset($_REQUEST['term'])) {\n        echo json_encode([]);\n    }\n    $suggestions = [];\n    $query = new WP_Query([\n        's' =&gt; $search_term,\n        'posts_per_page' =&gt; -1,\n    ]);\n    if ($query-&gt;have_posts()) {\n        while ($query-&gt;have_posts()) {\n            $query-&gt;the_post();\n            $suggestions[] = [\n                'id' =&gt; get_the_ID(),\n                'label' =&gt; get_the_title(),\n                'link' =&gt; get_the_permalink()\n            ];\n        }\n        wp_reset_postdata();\n    }\n    echo json_encode($suggestions);\n    wp_die();\n}<\/code><\/pre>\n<p>\u0421\u043f\u043e\u0447\u0430\u0442\u043a\u0443 \u043c\u0438 \u043f\u0435\u0440\u0435\u0432\u0456\u0440\u044f\u0454\u043c\u043e, \u0447\u0438 \u0431\u0443\u0432 \u043e\u0434\u043d\u043e\u0440\u0430\u0437\u043e\u0432\u0438\u0439 \u043d\u043e\u043c\u0435\u0440 \u0434\u0456\u0439\u0441\u043d\u0438\u043c \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044f \u043f\u0435\u0432\u043d\u043e\u0457 \u0431\u0435\u0437\u043f\u0435\u043a\u0438 \u043d\u0430\u0448\u0438\u0445 \u0432\u0438\u043a\u043b\u0438\u043a\u0456\u0432 AJAX. \u041c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0437\u0440\u043e\u0431\u0438\u0442\u0438 \u0446\u0435, \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u0432\u0448\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e <code>[check_ajax_referer](https:\/\/developer.wordpress.org\/reference\/functions\/check_ajax_referer\/)()<\/code>. \u042f \u0442\u0430\u043a\u043e\u0436 \u0434\u043e\u0434\u0430\u0432 \u043a\u043e\u0434, \u0449\u043e\u0431 \u0433\u0430\u0440\u0430\u043d\u0442\u0443\u0432\u0430\u0442\u0438, \u0449\u043e \u043c\u0438 \u043d\u0435 \u0432\u0438\u043a\u043e\u043d\u0443\u0454\u043c\u043e \u0432\u0430\u0436\u043a\u0438\u0439 \u0437\u0430\u043f\u0438\u0442, \u044f\u043a\u0449\u043e \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0438\u0439 \u043f\u043e\u0448\u0443\u043a\u043e\u0432\u0438\u0439 \u0442\u0435\u0440\u043c\u0456\u043d \u0431\u0443\u0432 \u043f\u043e\u0440\u043e\u0436\u043d\u0456\u043c. \u041f\u043e\u0442\u0456\u043c \u043c\u0438 \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u0438 \u043f\u043e\u0440\u043e\u0436\u043d\u0456\u0439 \u043c\u0430\u0441\u0438\u0432, \u0437\u0430\u043a\u043e\u0434\u043e\u0432\u0430\u043d\u0438\u0439 \u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0456 json.<\/p>\n<p>\u041d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0439 \u0432\u0438\u0449\u0435 \u043f\u0440\u0438\u043a\u043b\u0430\u0434 \u043a\u043e\u0434\u0443 \u0432\u0438\u043a\u043e\u043d\u0443\u0454 <code>[WP_Query](https:\/\/developer.wordpress.org\/reference\/classes\/wp_query\/)<\/code>\u043f\u043e\u0448\u0443\u043a \u0437\u0430 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u043c \u0442\u0435\u0440\u043c\u0456\u043d\u043e\u043c. \u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0438 <code>posts_per_page<\/code>as, <code>-1<\/code>\u0449\u043e\u0431 \u0433\u0430\u0440\u0430\u043d\u0442\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0432\u0435\u0440\u043d\u0435\u043d\u043d\u044f \u0432\u0441\u0456\u0445 \u0437\u0431\u0456\u0433\u0456\u0432. \u041f\u0435\u0440\u0435\u0433\u043b\u044f\u043d\u044c\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0456\u044e, <code>WP_Query<\/code>\u044f\u043a\u0449\u043e \u0432\u0438 \u0445\u043e\u0447\u0435\u0442\u0435 \u0434\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u043e \u043d\u0430\u043b\u0430\u0448\u0442\u0443\u0432\u0430\u0442\u0438 \u0437\u0430\u043f\u0438\u0442.<\/p>\n<p>\u041f\u043e\u0442\u0456\u043c \u043c\u0438 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0430\u0454\u043c\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0438 (\u0440\u044f\u0434\u043e\u043a <code>#17<\/code>) \u0456 \u0437\u0430\u043f\u043e\u0432\u043d\u044e\u0454\u043c\u043e \u043c\u0430\u0441\u0438\u0432 \u0437\u0431\u0456\u0433\u0430\u043c\u0438 (\u0440\u044f\u0434\u043e\u043a <code>#19-23<\/code>). \u0424\u0443\u043d\u043a\u0446\u0456\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f jQuery UI \u0432\u0438\u043c\u0430\u0433\u0430\u0454 \u044f\u043a \u043c\u0456\u043d\u0456\u043c\u0443\u043c \u043c\u043e\u0436\u043b\u0438\u0432\u043e\u0441\u0442\u0456 \u0432\u043a\u0430\u0437\u0443\u0432\u0430\u0442\u0438 <code>label<\/code>, \u0449\u043e \u043c\u0430\u0454 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u0438\u0441\u044f \u0443 \u0432\u0456\u043a\u043d\u0456 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f. \u041c\u0438 \u0442\u0430\u043a\u043e\u0436 \u043f\u0435\u0440\u0435\u0434\u0430\u0454\u043c\u043e \u043f\u043e\u0441\u0442\u0456\u0439\u043d\u0456 \u043f\u043e\u0441\u0438\u043b\u0430\u043d\u043d\u044f \u0432 \u043a\u043b\u044e\u0447\u0456 \u00ab<code>link<\/code>\u00bb, \u044f\u043a\u0438\u0439 \u043c\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u043c\u043e \u0432 \u043d\u0430\u0448\u043e\u043c\u0443 \u043a\u043e\u0434\u0456 Javascript \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044f \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0430.<\/p>\n<p>\u041d\u0430\u0440\u0435\u0448\u0442\u0456, \u0443 \u0440\u044f\u0434\u043a\u0443 <code>#27<\/code>\u043c\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u044e\u0454\u043c\u043e \u0437\u0433\u0435\u043d\u0435\u0440\u043e\u0432\u0430\u043d\u0438\u0439 \u043c\u0430\u0441\u0438\u0432 \u044f\u043a JSON \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e <code>[json_encode](https:\/\/www.php.net\/manual\/en\/function.json-encode.php)()<\/code>.<\/p>\n<p>\u0417 \u0446\u0456\u0454\u044e \u0447\u0430\u0441\u0442\u0438\u043d\u043e\u044e PHP \u043d\u0430\u0448\u0435 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u0430\u0454 \u043f\u0440\u0430\u0446\u044e\u0432\u0430\u0442\u0438! \u041e\u043d\u043e\u0432\u0456\u0442\u044c \u0441\u0432\u0456\u0439 \u0441\u0430\u0439\u0442 \u0456 \u0441\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435!<\/p>\n<h2>\u0414\u043e\u0434\u0430\u0442\u043a\u043e\u0432\u0456 \u043f\u043e\u043a\u0440\u0430\u0449\u0435\u043d\u043d\u044f<\/h2>\n<p>\u041e\u0434\u043d\u0430 \u0437 \u043f\u043e\u0448\u0438\u0440\u0435\u043d\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043f\u043e\u043b\u044f\u0433\u0430\u0454 \u0432 \u0442\u043e\u043c\u0443, \u0449\u043e \u043a\u0456\u043b\u044c\u043a\u0456\u0441\u0442\u044c \u0437\u0431\u0456\u0433\u0456\u0432 \u0437\u0430\u0431\u0430\u0433\u0430\u0442\u043e, \u0430 \u0432\u0456\u043a\u043d\u043e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0441\u0442\u0430\u0454 \u0437\u0430\u043d\u0430\u0434\u0442\u043e \u0432\u0435\u043b\u0438\u043a\u0438\u043c. \u0414\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u0454 \u0434\u0432\u0430 \u0440\u0456\u0448\u0435\u043d\u043d\u044f.<\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0456\u0437 \u0440\u0456\u0448\u0435\u043d\u044c \u0454 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u043e\u0441\u0442\u0456 <code>minLength<\/code>\u0434\u043e <code>autocomplete()<\/code>\u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u0432 Javascript. \u0426\u044f \u0432\u043b\u0430\u0441\u0442\u0438\u0432\u0456\u0441\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u0438\u043c\u0435 \u0432\u0456\u043a\u043d\u043e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043b\u0438\u0448\u0435 \u043f\u0456\u0441\u043b\u044f \u0432\u0432\u0435\u0434\u0435\u043d\u043d\u044f \u043f\u0435\u0432\u043d\u043e\u0457 \u043a\u0456\u043b\u044c\u043a\u043e\u0441\u0442\u0456 \u0441\u0438\u043c\u0432\u043e\u043b\u0456\u0432. \u042f\u043a \u043f\u0440\u0438\u043a\u043b\u0430\u0434, \u043c\u0438 \u043c\u043e\u0436\u0435\u043c\u043e \u0432\u0438\u043c\u0430\u0433\u0430\u0442\u0438 \u0449\u043e\u043d\u0430\u0439\u043c\u0435\u043d\u0448\u0435 3 \u0441\u0438\u043c\u0432\u043e\u043b\u0438 \u043f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f:<\/p>\n<pre><code>        ...\n        select: function(event, ui) {\n            window.location.href = ui.item.link;\n        },\n        minLength: 3,\n    });\n});<\/code><\/pre>\n<p>jQuery UI Autocomplete \u043f\u0440\u043e\u043f\u043e\u043d\u0443\u0454 <a href=\"https:\/\/jqueryui.com\/autocomplete\/#maxheight\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u0456\u043d\u0448\u0435 \u0440\u0456\u0448\u0435\u043d\u043d\u044f \u0442\u0443\u0442<\/a>. \u0412\u0456\u043d \u043f\u043e\u043a\u0430\u0437\u0443\u0454 \u043f\u0440\u0438\u043a\u043b\u0430\u0434 \u0434\u043e\u0434\u0430\u0432\u0430\u043d\u043d\u044f \u0442\u0440\u043e\u0445\u0438 CSS, \u0449\u043e\u0431 \u0434\u043e\u0434\u0430\u0442\u0438 \u0444\u0456\u043a\u0441\u043e\u0432\u0430\u043d\u0443 \u0432\u0438\u0441\u043e\u0442\u0443 \u0442\u0430 \u0432\u043d\u0443\u0442\u0440\u0456\u0448\u043d\u044e \u0441\u043c\u0443\u0433\u0443 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u0443 \u043f\u043e\u043b\u0456 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f.<\/p>\n<h2>\u0412\u0438\u0441\u043d\u043e\u0432\u043e\u043a \u0456 \u043f\u043e\u0432\u043d\u0438\u0439 \u043a\u043e\u0434<\/h2>\n<p>\u041c\u0438 \u0443\u0441\u043f\u0456\u0448\u043d\u043e \u0434\u043e\u0434\u0430\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u0434\u043e \u0444\u0443\u043d\u043a\u0446\u0456\u0457 \u043f\u043e\u0448\u0443\u043a\u0443 WordPress, \u0434\u0435 \u043c\u0438 \u043c\u0430\u0454\u043c\u043e \u043f\u043e\u0432\u043d\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0437\u0431\u0456\u0433\u0430\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0432\u0435\u0440\u043d\u0435\u043d\u043d\u044f. \u0426\u0435 \u0434\u0430\u0454 \u0432\u0456\u0434\u0432\u0456\u0434\u0443\u0432\u0430\u0447\u0430\u043c \u0448\u0432\u0438\u0434\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u0456\u0431 \u043d\u0430\u0432\u0456\u0433\u0430\u0446\u0456\u0457 \u043f\u043e \u0432\u0430\u0448\u043e\u043c\u0443 \u0432\u043c\u0456\u0441\u0442\u0443, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u043d\u0430\u0442\u0438\u0441\u043a\u0430\u043d\u043d\u044f \u0437\u0431\u0456\u0433\u0443 \u043f\u0435\u0440\u0435\u0441\u043f\u0440\u044f\u043c\u043e\u0432\u0443\u0454 \u0431\u0435\u0437\u043f\u043e\u0441\u0435\u0440\u0435\u0434\u043d\u044c\u043e \u0434\u043e \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457, \u0430 \u043d\u0435 \u0432 \u043e\u0431\u0445\u0456\u0434 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0456\u0432 \u043f\u043e\u0448\u0443\u043a\u0443. \u0420\u0435\u0430\u043b\u0456\u0437\u0430\u0446\u0456\u044f \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f \u043c\u043e\u0436\u0435 \u043d\u0435 \u0437\u0430\u0432\u0436\u0434\u0438 \u043c\u0430\u0442\u0438 \u0441\u0435\u043d\u0441 \u043d\u0430 \u0432\u0441\u0456\u0445 \u0441\u0430\u0439\u0442\u0430\u0445 WordPress, \u0430\u043b\u0435 \u043c\u043e\u0436\u0435 \u0431\u0443\u0442\u0438 \u0447\u0443\u0434\u043e\u0432\u043e\u044e \u0434\u043b\u044f \u043f\u043e\u0448\u0443\u043a\u0443 \u043f\u0435\u0432\u043d\u043e\u0433\u043e \u0432\u043c\u0456\u0441\u0442\u0443 \u0430\u0431\u043e \u0432 \u0441\u043f\u0435\u0446\u0456\u0430\u043b\u044c\u043d\u0438\u0445 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445!<\/p>\n<p>\u041e\u0441\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e:<\/p>\n<pre><code>add_action('wp_enqueue_scripts', function() {\n    wp_enqueue_script('autocomplete-search', get_stylesheet_directory_uri(). '\/assets\/js\/autocomplete.js', \n        ['jquery', 'jquery-ui-autocomplete'], null, true);\n    wp_localize_script('autocomplete-search', 'AutocompleteSearch', [\n        'ajax_url' =&gt; admin_url('admin-ajax.php'),\n        'ajax_nonce' =&gt; wp_create_nonce('autocompleteSearchNonce')\n    ]);\n\u00a0\n    $wp_scripts = wp_scripts();\n    wp_enqueue_style('jquery-ui-css',\n        '\/\/ajax.googleapis.com\/ajax\/libs\/jqueryui\/'. $wp_scripts-&gt;registered['jquery-ui-autocomplete']-&gt;ver. '\/themes\/smoothness\/jquery-ui.css',\n        false, null, false\n    );\n});\n\u00a0\nadd_action('wp_ajax_nopriv_autocompleteSearch', 'awp_autocomplete_search');\nadd_action('wp_ajax_autocompleteSearch', 'awp_autocomplete_search');\nfunction awp_autocomplete_search() {\n    check_ajax_referer('autocompleteSearchNonce', 'security');\n\u00a0\n    $search_term = $_REQUEST['term'];\n    if (!isset($_REQUEST['term'])) {\n        echo json_encode([]);\n    }\n\u00a0\n    $suggestions = [];\n    $query = new WP_Query([\n        's' =&gt; $search_term,\n        'posts_per_page' =&gt; -1,\n    ]);\n    if ($query-&gt;have_posts()) {\n        while ($query-&gt;have_posts()) {\n            $query-&gt;the_post();\n            $suggestions[] = [\n                'id' =&gt; get_the_ID(),\n                'label' =&gt; get_the_title(),\n                'link' =&gt; get_the_permalink()\n            ];\n        }\n        wp_reset_postdata();\n    }\n    echo json_encode($suggestions);\n    wp_die();\n}<\/code><\/pre>\n<pre><code>jQuery(function($) {\n    $('.search-form .search-field').autocomplete({\n        source: function(request, response) {\n            $.ajax({\n                dataType: 'json',\n                url: AutocompleteSearch.ajax_url,\n                data: {\n                    term: request.term,\n                    action: 'autocompleteSearch',\n                    security: AutocompleteSearch.ajax_nonce,\n                },\n                success: function(data) {\n                    response(data);\n                }\n            });\n        },\n        select: function(event, ui) {\n            window.location.href = ui.item.link;\n        },\n    });\n});<\/code><\/pre>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/awhitepixel.com\" class=\"external external_icon\">awhitepixel.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0426\u0435\u0439 \u043f\u0456\u0434\u0440\u0443\u0447\u043d\u0438\u043a \u043f\u0440\u0438\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0434\u043b\u044f \u0442\u0438\u0445, \u0445\u0442\u043e \u0445\u043e\u0447\u0435 \u0440\u0435\u0430\u043b\u0456\u0437\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0448\u0443\u043a \u0456\u0437 \u0430\u0432\u0442\u043e\u0437\u0430\u043f\u043e\u0432\u043d\u0435\u043d\u043d\u044f\u043c \u0443 WordPress, \u0434\u0435 \u043c\u0438 \u043f\u043e\u0432\u043d\u0456\u0441\u0442\u044e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044e\u0454\u043c\u043e \u0437\u0431\u0456\u0433\u0438, \u0449\u043e \u043f\u043e\u0432\u0435\u0440\u0442\u0430\u044e\u0442\u044c\u0441\u044f.<\/p>\n","protected":false},"author":1,"featured_media":224845,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[902,725,1110,808,808,839,849,869,869,839,902,849,725],"tags":[1174],"class_list":["post-233354","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-kod-3","category-rozrobnyk","category-n-a","category-php-10","category-kerivnytstvo-dlia-pochatkivtsiv","category-pidruchnyky","category-wordpress-10","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/comments?post=233354"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/posts\/233354\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media\/224845"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/media?parent=233354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/categories?post=233354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/uk\/wp-json\/wp\/v2\/tags?post=233354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}