{"id":28287,"date":"2021-05-20T12:13:00","date_gmt":"2021-05-20T09:13:00","guid":{"rendered":"https:\/\/themewp.inform.click\/?p=28287"},"modified":"2025-02-12T05:54:23","modified_gmt":"2025-02-12T02:54:23","slug":"jak-zavantazhuvati-povidomlennja-v-wordpress-za-dopomogoju-ajax","status":"publish","type":"post","link":"https:\/\/themewp.inform.click\/uk\/jak-zavantazhuvati-povidomlennja-v-wordpress-za-dopomogoju-ajax\/","title":{"rendered":"\u042f\u043a \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0432\u0430\u0442\u0438 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f \u0432 WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e AJAX"},"content":{"rendered":"<p>\u042f \u0432\u0435\u0434\u0443 <a href=\"https:\/\/www.youtube.com\/channel\/UCosi8Kv8-EPLt5TBJLlsWJA\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">\u043a\u0430\u043d\u0430\u043b YouTube,<\/a> \u0434\u0435 \u043f\u0443\u0431\u043b\u0456\u043a\u0443\u044e \u0432\u0456\u0434\u0435\u043e, \u043f\u043e\u0432&#8217;\u044f\u0437\u0430\u043d\u0456 \u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0443\u0432\u0430\u043d\u043d\u044f\u043c \u0442\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043d\u0438\u043c \u0437\u0430\u0431\u0435\u0437\u043f\u0435\u0447\u0435\u043d\u043d\u044f\u043c. \u041d\u0435\u0449\u043e\u0434\u0430\u0432\u043d\u043e \u043e\u0434\u0438\u043d \u0437 \u0430\u0431\u043e\u043d\u0435\u043d\u0442\u0456\u0432 \u0437\u0430\u043f\u0438\u0442\u0430\u0432 \u043c\u0435\u043d\u0435, \u044f\u043a \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0434\u043e\u043f\u0438\u0441 WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e AJAX. \u0423 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u044c \u043d\u0430 \u043d\u044c\u043e\u0433\u043e \u044f \u0432\u0438\u0440\u0456\u0448\u0438\u0432 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u0438 \u0434\u043e\u043f\u0438\u0441 \u043d\u0430 \u0439\u043e\u0433\u043e \u0437\u0430\u043f\u0438\u0442\u0430\u043d\u043d\u044f. \u041e\u0442\u0436\u0435, \u0443 \u0446\u0456\u0439 \u0441\u0442\u0430\u0442\u0442\u0456 \u043c\u0438 \u0432\u0438\u0432\u0447\u0430\u0454\u043c\u043e, \u044f\u043a \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u044e WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e AJAX, \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u044e\u0447\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f \u0431\u0456\u043b\u044c\u0448\u0435 \u0442\u0430 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0443\u0432\u0430\u043d\u043d\u044f \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438.<\/p>\n<p>\u0420\u0456\u0437\u043d\u0438\u0446\u044f \u043c\u0456\u0436 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f\u043c \u0431\u0456\u043b\u044c\u0448\u0435 \u0456 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u043e\u044e \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438 \u0434\u043e\u0441\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0430. \u041a\u043e\u043b\u0438 \u0432\u0438 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435, \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043d\u0430\u0442\u0438\u0441\u043d\u0443\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0443, \u0449\u043e\u0431 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u043d\u0430\u0431\u0456\u0440 \u0434\u043e\u043f\u0438\u0441\u0456\u0432. \u0410 \u043f\u0440\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u0446\u0456 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438, \u043a\u043e\u043b\u0438 \u0432\u0438 \u043f\u0440\u043e\u043a\u0440\u0443\u0447\u0443\u0454\u0442\u0435 \u043a\u0456\u043d\u0435\u0446\u044c \u043e\u0431\u043b\u0430\u0441\u0442\u0456 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0443, \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u043d\u0430\u0431\u0456\u0440 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u044c \u043f\u043e\u0432\u0438\u043d\u0435\u043d \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u043d\u043e \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0443\u0432\u0430\u0442\u0438\u0441\u044f.<\/p>\n<p>\u041f\u0440\u0438\u043f\u0443\u0441\u0442\u0438\u043c\u043e, \u0443 \u0432\u0430\u0441 \u0454 \u043a\u0456\u043b\u044c\u043a\u0430 \u0434\u043e\u043f\u0438\u0441\u0456\u0432, \u0456 \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0438 2 \u0434\u043e\u043f\u0438\u0441\u0438 \u043f\u0440\u0438 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u0456 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438, \u0430 \u043f\u043e\u0442\u0456\u043c, \u043d\u0430\u0442\u0438\u0441\u043d\u0443\u0432\u0448\u0438 &quot;\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435&quot; \u0430\u0431\u043e &quot;\u041f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438&quot;, \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0438\u0441\u044f \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0456 2 \u0434\u043e\u043f\u0438\u0441\u0438. \u0426\u0435\u0439 \u043f\u0440\u043e\u0446\u0435\u0441 \u0442\u0440\u0438\u0432\u0430\u0442\u0438\u043c\u0435 \u0434\u043e\u0442\u0438, \u0434\u043e\u043a\u0438 \u043d\u0435 \u0437\u2019\u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0456 \u0432\u0430\u0448\u0456 \u0434\u043e\u043f\u0438\u0441\u0438.<\/p>\n<p>\u0421\u0442\u0432\u043e\u0440\u0456\u0442\u044c \u043d\u043e\u0432\u0443 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 \u043f\u0456\u0434 \u043d\u0430\u0437\u0432\u043e\u044e &quot;\u0411\u043b\u043e\u0433&quot;. \u0414\u043b\u044f \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043d\u044f \u0441\u0432\u043e\u0457\u0445 \u0434\u043e\u043f\u0438\u0441\u0456\u0432 \u043d\u0430 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456 \u0431\u043b\u043e\u0433\u0443 \u0441\u0442\u0432\u043e\u0440\u0456\u0442\u044c \u0432\u043b\u0430\u0441\u043d\u0438\u0439 \u0448\u0430\u0431\u043b\u043e\u043d <code>page-blog.php<\/code>\u0443 \u043a\u0430\u0442\u0430\u043b\u043e\u0437\u0456 \u0432\u0430\u0448\u043e\u0457 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0457 \u0442\u0435\u043c\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440, \u043a\u043e\u043b\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456 \u0432\u0456\u0434\u0432\u0456\u0434\u0443\u044e\u0442\u044c \u0432\u0430\u0448\u0443 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443 \u0431\u043b\u043e\u0433\u0443, \u0432\u043e\u043d\u0438 \u043f\u043e\u0432\u0438\u043d\u043d\u0456 \u043f\u043e\u0431\u0430\u0447\u0438\u0442\u0438 2 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f. \u041e\u0442\u0436\u0435, \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u043a\u043e\u0434 \u043d\u0438\u0436\u0447\u0435 \u0443 \u0444\u0430\u0439\u043b \u0432\u043b\u0430\u0441\u043d\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0443.<\/p>\n<pre><code>&lt;div class=\"entry-content\"&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;?php\n\u00a0\u00a0\u00a0\u00a0$args = array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'post_type' =&gt; 'post',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'post_status' =&gt; 'publish',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'posts_per_page' =&gt; '2',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'paged' =&gt; 1,\n\u00a0\u00a0\u00a0\u00a0);\n\u00a0\u00a0\u00a0\u00a0$blog_posts = new WP_Query( $args );\n\u00a0\u00a0\u00a0\u00a0?&gt;\n\u00a0\n\u00a0\u00a0\u00a0\u00a0&lt;?php if ($blog_posts-&gt;have_posts() ): ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;div class=\"blog-posts\"&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php while ($blog_posts-&gt;have_posts() ): $blog_posts-&gt;the_post(); ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;\/h2&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php the_excerpt(); ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php endwhile; ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;\/div&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;div class=\"loadmore\"&gt;Load More...&lt;\/div&gt;\n\u00a0\u00a0\u00a0\u00a0&lt;?php endif; ?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u0422\u0443\u0442 \u044f \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u0430\u0432 \u00ab\u043f\u0456\u0434\u043a\u0430\u0447\u0443\u0432\u0430\u043d\u0438\u0439\u00bb \u043a\u043b\u044e\u0447 \u0456 \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0439\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f \u00ab1\u00bb. &quot;paged&quot; &#8211; \u0446\u0435 \u043a\u043b\u044e\u0447, \u044f\u043a\u0438\u0439 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u0442\u044c\u0441\u044f \u0432 WordPress, \u043a\u043e\u043b\u0438 \u0439\u0434\u0435\u0442\u044c\u0441\u044f \u043f\u0440\u043e \u043f\u0430\u0433\u0456\u043d\u0430\u0446\u0456\u044e. &#8216;paged&#8217; =&gt; 1 \u043e\u0437\u043d\u0430\u0447\u0430\u0454 \u043f\u0435\u0440\u0448\u0443 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0443.<\/p>\n<p>\u0412\u0438 \u043f\u043e\u043c\u0456\u0442\u0438\u043b\u0438 \u0431\u0438 \u0435\u043b\u0435\u043c\u0435\u043d\u0442 div \u0456\u0437 \u043a\u043b\u0430\u0441\u043e\u043c &#8216;loadmore&#8217;. \u041f\u0456\u0441\u043b\u044f \u043d\u0430\u0442\u0438\u0441\u043a\u0430\u043d\u043d\u044f \u043a\u043d\u043e\u043f\u043a\u0438 \u00ab\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435\u00bb \u043c\u0438 \u0437\u0430\u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0443\u0454\u043c\u043e Ajax \u0456 \u043e\u0442\u0440\u0438\u043c\u0430\u0454\u043c\u043e \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0438\u0439 \u043d\u0430\u0431\u0456\u0440 \u0434\u043e\u043f\u0438\u0441\u0456\u0432.<\/p>\n<h3>\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0442\u0435 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e Ajax \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e \u043a\u043d\u043e\u043f\u043a\u0438 &quot;\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435&quot;<\/h3>\n<p>\u0429\u043e\u0431 \u0437\u0434\u0456\u0439\u0441\u043d\u0438\u0442\u0438 \u0432\u0438\u043a\u043b\u0438\u043a Ajax, \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0438 \u0444\u0430\u0439\u043b JS \u0443 \u0441\u0435\u0440\u0435\u0434\u043e\u0432\u0438\u0449\u0435 WordPress. \u0421\u0442\u0432\u043e\u0440\u0456\u0442\u044c <code>custom.js<\/code>\u0444\u0430\u0439\u043b \u0432\u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0456 <code>js<\/code>\u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0443, \u0430 \u043f\u043e\u0442\u0456\u043c \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u043d\u0438\u0436\u0447\u0435 <code>functions.php<\/code>\u0444\u0430\u0439\u043b \u0443 \u0444\u0430\u0439\u043b.<\/p>\n<pre><code>function blog_scripts() {\n\u00a0\u00a0\u00a0\u00a0\/\/ Register the script\n\u00a0\u00a0\u00a0\u00a0wp_register_script( 'custom-script', get_stylesheet_directory_uri(). '\/js\/custom.js', array('jquery'), false, true );\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\/\/ Localize the script with new data\n\u00a0\u00a0\u00a0\u00a0$script_data_array = array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ),\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'security' =&gt; wp_create_nonce( 'load_more_posts' ),\n\u00a0\u00a0\u00a0\u00a0);\n\u00a0\u00a0\u00a0\u00a0wp_localize_script( 'custom-script', 'blog', $script_data_array );\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\/\/ Enqueued script with localized data.\n\u00a0\u00a0\u00a0\u00a0wp_enqueue_script( 'custom-script' );\n}\nadd_action( 'wp_enqueue_scripts', 'blog_scripts' );<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0456, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u043f\u0438\u0448\u0435\u043c\u043e \u0442\u0440\u043e\u0445\u0438 jQuery \u0442\u0430 \u043d\u0430\u0434\u0456\u0448\u043b\u0435\u043c\u043e \u0432\u0438\u043a\u043b\u0438\u043a Ajax, \u044f\u043a\u0438\u0439 \u043d\u0430\u0442\u043e\u043c\u0456\u0441\u0442\u044c \u0434\u0430\u0441\u0442\u044c \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0456 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f.<\/p>\n<p><strong>custom.js<\/strong><\/p>\n<pre><code>var page = 2;\njQuery(function($) {\n\u00a0\u00a0\u00a0\u00a0$('body').on('click', '.loadmore', function() {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var data = {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action': 'load_posts_by_ajax',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'page': page,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'security': blog.security\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$.post(blog.ajaxurl, data, function(response) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if($.trim(response) != '') {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$('.blog-posts').append(response);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0page++;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$('.loadmore').hide();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0});\n});<\/code><\/pre>\n<p>\u0422\u0435, \u0449\u043e \u043c\u0438 \u0442\u0443\u0442 \u0440\u043e\u0431\u0438\u043c\u043e, \u0446\u0435 \u0442\u0435, \u0449\u043e \u044f \u0432\u0437\u044f\u0432 \u0437\u043c\u0456\u043d\u043d\u0443 javascript &#8216;page&#8217; \u0437 \u043f\u043e\u0447\u0430\u0442\u043a\u043e\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044f\u043c 2, \u043e\u0441\u043a\u0456\u043b\u044c\u043a\u0438 \u043c\u0438 \u0437\u0431\u0438\u0440\u0430\u0454\u043c\u043e\u0441\u044f \u0440\u043e\u0437\u043f\u043e\u0447\u0430\u0442\u0438 \u0437 \u0440\u043e\u0437\u043c\u0456\u0449\u0435\u043d\u043d\u044f \u0441\u0442\u043e\u0440\u0456\u043d\u043e\u043a \u043d\u0430 \u0434\u0440\u0443\u0433\u0456\u0439 \u0441\u0442\u043e\u0440\u0456\u043d\u0446\u0456. \u042f \u0437\u0431\u0456\u043b\u044c\u0448\u0443\u044e \u0446\u044e \u0437\u043c\u0456\u043d\u043d\u0443 &quot;\u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438&quot; \u043f\u0456\u0441\u043b\u044f \u043e\u0442\u0440\u0438\u043c\u0430\u043d\u043d\u044f \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u0456 Ajax. \u041e\u0442\u0440\u0438\u043c\u0430\u0432\u0448\u0438 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u044c, \u044f \u0434\u043e\u0434\u0430\u044e \u0457\u0457 \u0434\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0456\u0441\u043d\u0443\u044e\u0447\u0438\u0445 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0439.<\/p>\n<p>\u042f \u0442\u0430\u043a\u043e\u0436 \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u0456\u0457 \u044f\u043a &#8216;load_posts_by_ajax&#8217; \u0434\u043b\u044f \u0432\u0438\u043a\u043b\u0438\u043a\u0443 Ajax, \u044f\u043a\u0438\u0439 \u043f\u043e\u0432\u0438\u043d\u0435\u043d \u0431\u0443\u0442\u0438 \u0437\u0456\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0439 \u0437 \u0434\u0456\u044f\u043c\u0438 WordPress. \u0412\u0456\u0434\u043a\u0440\u0438\u0439\u0442\u0435 <code>functions.php<\/code>\u0444\u0430\u0439\u043b \u0456 \u0434\u043e\u0434\u0430\u0439\u0442\u0435 \u0432 \u0444\u0430\u0439\u043b \u043a\u043e\u0434 \u043d\u0438\u0436\u0447\u0435.<\/p>\n<pre><code>add_action('wp_ajax_load_posts_by_ajax', 'load_posts_by_ajax_callback');\nadd_action('wp_ajax_nopriv_load_posts_by_ajax', 'load_posts_by_ajax_callback');<\/code><\/pre>\n<p>\u0423 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u0438\u0445 \u0432\u0438\u0449\u0435 \u0434\u0456\u044f\u0445 WordPress \u043c\u0438 \u0432\u0438\u043a\u043b\u0438\u043a\u0430\u0454\u043c\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, <code>load_posts_by_ajax_callback<\/code>\u044f\u043a\u0443 \u044f \u0437\u0431\u0438\u0440\u0430\u044e\u0441\u044f \u0432\u0438\u0437\u043d\u0430\u0447\u0438\u0442\u0438 \u043d\u0430 \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u043e\u043c\u0443 \u043a\u0440\u043e\u0446\u0456. \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u0438\u0437\u043d\u0430\u0447\u0438\u0442\u0438 \u0446\u044e \u0444\u0443\u043d\u043a\u0446\u0456\u044e \u0443 \u0441\u0432\u043e\u0454\u043c\u0443 <code>functions.php<\/code>.<\/p>\n<pre><code>function load_posts_by_ajax_callback() {\n\u00a0\u00a0\u00a0\u00a0check_ajax_referer('load_more_posts', 'security');\n\u00a0\u00a0\u00a0\u00a0$paged = $_POST['page'];\n\u00a0\u00a0\u00a0\u00a0$args = array(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'post_type' =&gt; 'post',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'post_status' =&gt; 'publish',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'posts_per_page' =&gt; '2',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'paged' =&gt; $paged,\n\u00a0\u00a0\u00a0\u00a0);\n\u00a0\u00a0\u00a0\u00a0$blog_posts = new WP_Query( $args );\n\u00a0\u00a0\u00a0\u00a0?&gt;\n\u00a0\n\u00a0\u00a0\u00a0\u00a0&lt;?php if ($blog_posts-&gt;have_posts() ): ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php while ($blog_posts-&gt;have_posts() ): $blog_posts-&gt;the_post(); ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;\/h2&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php the_excerpt(); ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php endwhile; ?&gt;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;?php\n\u00a0\u00a0\u00a0\u00a0endif;\n\u00a0\n\u00a0\u00a0\u00a0\u00a0wp_die();\n}<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440, \u043a\u043e\u043b\u0438 \u0432\u0438 \u043d\u0430\u0442\u0438\u0441\u043a\u0430\u0454\u0442\u0435 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435\u00bb, \u0432\u043e\u043d\u0430 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0443\u043f\u043d\u0456 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f \u0447\u0435\u0440\u0435\u0437 Ajax \u0456 \u043f\u043e\u0432\u0435\u0440\u043d\u0435 \u0457\u0445 \u043d\u0430\u0437\u0430\u0434 \u0443 \u0432\u0456\u0434\u043f\u043e\u0432\u0456\u0434\u044c. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0432\u0438\u0449\u0435 \u043a\u043e\u0434 JavaScript \u043e\u0431\u0440\u043e\u0431\u043b\u044f\u0454 \u0440\u0435\u0448\u0442\u0443 \u0440\u0435\u0447\u0435\u0439.<\/p>\n<h3>\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0442\u0435 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f WordPress \u0437\u0430 \u0434\u043e\u043f\u043e\u043c\u043e\u0433\u043e\u044e Ajax \u0434\u043b\u044f \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438<\/h3>\n<p>\u0414\u0435\u044f\u043a\u0456 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447\u0456 \u043c\u043e\u0436\u0443\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0456\u0442\u0438 \u043a\u043d\u043e\u043f\u043a\u0443 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f \u0431\u0456\u043b\u044c\u0448\u0435, \u0449\u043e\u0431 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u0438 \u043f\u043e\u0432\u0456\u0434\u043e\u043c\u043b\u0435\u043d\u043d\u044f \u0432 Ajax. \u041d\u0430\u0442\u043e\u043c\u0456\u0441\u0442\u044c \u0432\u043e\u043d\u0438 \u0432\u0432\u0430\u0436\u0430\u044e\u0442\u044c \u0437\u0430 \u043a\u0440\u0430\u0449\u0435, \u0449\u043e\u0431 \u043f\u0443\u0431\u043b\u0456\u043a\u0430\u0446\u0456\u0457 \u0432\u0456\u0434\u043e\u0431\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044f, \u043a\u043e\u043b\u0438 \u043a\u043e\u0440\u0438\u0441\u0442\u0443\u0432\u0430\u0447 \u0434\u043e\u0441\u044f\u0433\u0430\u0454 \u043a\u0456\u043d\u0446\u044f \u043e\u0431\u043b\u0430\u0441\u0442\u0456 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0446\u044c\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0456\u0431\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u0438 \u043b\u043e\u0433\u0456\u043a\u0443, \u044f\u043a\u0430 \u0444\u0456\u043a\u0441\u0443\u0454 \u043f\u043e\u0434\u0456\u044e \u0432 \u043a\u0456\u043d\u0446\u0456 \u043e\u0431\u043b\u0430\u0441\u0442\u0456 \u043f\u0435\u0440\u0435\u0433\u043b\u044f\u0434\u0443, \u0440\u0435\u0448\u0442\u0430 \u043a\u043e\u0434\u0443 \u0442\u0430\u043a\u0430 \u0436, \u044f\u043a \u043a\u043d\u043e\u043f\u043a\u0430 \u00ab\u0417\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0438\u0442\u0438 \u0431\u0456\u043b\u044c\u0448\u0435\u00bb. \u041d\u0438\u0436\u0447\u0435 \u043d\u0430\u0432\u0435\u0434\u0435\u043d\u043e \u043a\u043e\u0434 jQuery \u0434\u043b\u044f \u043f\u0440\u043e\u043a\u0440\u0443\u0442\u043a\u0438 \u0441\u0442\u043e\u0440\u0456\u043d\u043a\u0438.<\/p>\n<pre><code>jQuery(window).scroll(function($) {\n\u00a0\u00a0\u00a0\u00a0if (jQuery(window).scrollTop() + jQuery(window).height() &gt; jQuery(document).height()) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var data = {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'action': 'load_posts_by_ajax',\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'page': page,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'security': blog.security\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\n\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$.post(blog.ajaxurl, data, function(response) {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if($.trim(response) != '') {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$('.blog-posts').append(response);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0page++;\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$('.loadmore').hide();\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\u00a0\u00a0\u00a0\u00a0}\n});<\/code><\/pre>\n<p>\u0426\u0435 \u0432\u043e\u043d\u043e! \u0412\u0438 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0431\u0443\u0432\u0430\u0442\u0438. \u042f \u0445\u043e\u0442\u0456\u0432 \u0431\u0438 \u0437\u043d\u0430\u0442\u0438 \u0432\u0430\u0448\u0456 \u0434\u0443\u043c\u043a\u0438 \u0442\u0430 \u043f\u0440\u043e\u043f\u043e\u0437\u0438\u0446\u0456\u0457 \u0432 \u043a\u043e\u043c\u0435\u043d\u0442\u0430\u0440\u044f\u0445 \u043d\u0438\u0436\u0447\u0435.<\/p>\n<h4>\u041f\u043e\u0432\u2019\u044f\u0437\u0430\u043d\u0456 \u0441\u0442\u0430\u0442\u0442\u0456<\/h4>\n<ul>\n<li><a href=\"https:\/\/themewp.inform.click\/uk\/jak-integruvati-zavantazhennja-fajliv-ajax-u-wordpress\/\" title=\"\u042f\u043a \u0456\u043d\u0442\u0435\u0433\u0440\u0443\u0432\u0430\u0442\u0438 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f \u0444\u0430\u0439\u043b\u0456\u0432 Ajax \u0443 WordPress\">\u042f\u043a \u0456\u043d\u0442\u0435\u0433\u0440\u0443\u0432\u0430\u0442\u0438 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f \u0444\u0430\u0439\u043b\u0456\u0432 Ajax \u0443 WordPress<\/a><\/li>\n<li><a href=\"https:\/\/themewp.inform.click\/uk\/jak-vikoristovuvati-jquery-ajax-u-wordpress\/\" title=\"\u042f\u043a \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 jQuery Ajax \u0443 WordPress\">\u042f\u043a \u0432\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0432\u0430\u0442\u0438 jQuery Ajax \u0443 WordPress<\/a><\/li>\n<\/ul>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">\u0414\u0436\u0435\u0440\u0435\u043b\u043e \u0437\u0430\u043f\u0438\u0441\u0443: artisansweb.net<\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0421\u044c\u043e\u0433\u043e\u0434\u043d\u0456 \u0434\u0443\u0436\u0435 \u043f\u043e\u0448\u0438\u0440\u0435\u043d\u0435 \u0437\u0430\u0432\u0430\u043d\u0442\u0430\u0436\u0435\u043d\u043d\u044f WordPress Post AJAX. WordPress \u043d\u0435 \u043d\u0430\u0434\u0430\u0454 \u0439\u043e\u0433\u043e \u0437\u0430 \u0437\u0430\u043c\u043e\u0432\u0447\u0443\u0432\u0430\u043d\u043d\u044f\u043c. \u0423 \u0446\u044c\u043e\u043c\u0443 \u043f\u043e\u0441\u0456\u0431\u043d\u0438\u043a\u0443 \u043c\u0438 \u043f\u043e\u044f\u0441\u043d\u044e\u0454\u043c\u043e, \u044f\u043a \u0432\u0438\u0440\u0456\u0448\u0438\u0442\u0438 \u0446\u0435 \u0437\u0430\u0432\u0434\u0430\u043d\u043d\u044f.<\/p>\n","protected":false},"author":1,"featured_media":21653,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[1],"tags":[851],"class_list":["post-28287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bez-kategorii","tag-affiai-uk"],"_links":{"self":[{"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/posts\/28287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/comments?post=28287"}],"version-history":[{"count":1,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/posts\/28287\/revisions"}],"predecessor-version":[{"id":513594,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/posts\/28287\/revisions\/513594"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/media\/21653"}],"wp:attachment":[{"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/media?parent=28287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/categories?post=28287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themewp.inform.click\/uk\/wp-json\/wp\/v2\/tags?post=28287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}